小编use*_*878的帖子

srand(time(null))导致编译器警告:隐式转换失去整数精度

如果这个问题已经得到解答,请道歉.

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main () {

srand( time(NULL) );
cout << rand();
}
Run Code Online (Sandbox Code Playgroud)

"隐式转换失去整数精度:'time_t'(又名'long')到'unsigned int'"

我执行上面的代码时得到的错误消息.我正在使用xcode 4.6.1.现在,当我使用不同的编译器,例如来自codepad.org的编译器时,它执行完全正常生成看起来像随机数,所以我假设它是一个xcode问题,我需要解决?

我已经开始编程了所以我是一个完整的初学者.我的代码有问题还是我的编译器?

任何帮助,将不胜感激!

c++ compiler-warnings

19
推荐指数
3
解决办法
3万
查看次数

标签 统计

c++ ×1

compiler-warnings ×1