全部问题 > 当前问题

我这个程序怎么会报错呢?

#include <stdio.h>
#include<stdlib.h>
#include<time.h>
main()
{
 int t,i;
 time(&t);
 srand(t);
for(i=1;i<=5;i++)
{
 printf("%d\n",rand());
}
}

郭碧婷 2015-8-21 11:23:35

共 7 个回答

嘿嘿大人 2015-8-21 11:24:46

是不是还有控制台没有关闭,就是那个黑框框

郭碧婷 2015-8-21 11:26:01

回复 嘿嘿大人:关了啊

嘿嘿大人 2015-8-21 11:27:08

回复 郭碧婷:那你重启一下软件吧,我用你的程序运行是正常的,或者你把报错给我看一下

我是学霸 2015-8-21 11:28:10

我运行的时候没有错误啊

郭碧婷 2015-8-21 11:28:18

回复 嘿嘿大人:error C2664: 'time' : cannot convert parameter 1 from 'int *' to 'long *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.

嘿嘿大人 2015-8-21 11:34:23

报错说是类型转换出错,但是没有这些错啊,只能给你重新打开软件建立一次文件来复制上去的建议,

祁老师 2015-8-21 11:35:41

回复 郭碧婷:vc++关闭 重新打开试一下

问题来自: 随机数