为什么编译通不过呢?

newer_zhk 2005-07-07 11:18:58
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main()
{
unsigned long a[12],b[12],c[12],d[12],f[12],w[12],tmp[12];
int i;
for(i=0;i<11;i++)
{
srand(time(0));
w[i]=rand();
printf("%x\n",w[i]);
}
getch();

}

用的win-tc

错误:
未定义的符号 '__STKLEN' 在模块 C0M
未定义的符号 '__HEAPLEN' 在模块 C0M
未定义的符号 '__SETARGV' 在模块 C0M
未定义的符号 '__SETENVP' 在模块 C0M
未定义的符号 '_MAIN' 在模块 C0M
未定义的符号 '_EXIT' 在模块 C0M
...全文
123 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dominic_Sena 2005-07-07
  • 打赏
  • 举报
回复
dev c++吧。
newer_zhk 2005-07-07
  • 打赏
  • 举报
回复
外面面应该一样的吧 我觉得可能时那个win-tc的原因 大家用的什么编译软件啊 tc不好用 有windows界面的编译软件么?象vc一样的那种 可以调试 中断等等调程序的
firstdreamer 2005-07-07
  • 打赏
  • 举报
回复
为什么不用dev c++呢,一个小巧的编译器,个人认为很不错!
firstdreamer 2005-07-07
  • 打赏
  • 举报
回复
如果要得到随机数就要把srand(time(0));放到循环体外面:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int main()
{
unsigned long a[12],b[12],c[12],d[12],f[12],w[12],tmp[12];
int i;
srand(time(0));
for(i=0;i<11;i++)
{
w[i]=(unsigned long)rand();
printf("%x\n",w[i]);
}
getchar();

}

-------------- Output --------------
c5d
519d
6e78
1ac6
7329
6049
4b85
71aa
899
24e3
7530
newer_zhk 2005-07-07
  • 打赏
  • 举报
回复
我也不知道win-tc用的什么编译器 可能和tc一样吧
firstdreamer 2005-07-07
  • 打赏
  • 举报
回复
楼主用的什么编译器,我用dev c++可以编译运行!不过输出结果是:

7733
7733
7733
7733
7733
7733
7733
7733
7733
7733
7733
newer_zhk 2005-07-07
  • 打赏
  • 举报
回复
还有个问题
怎么那个srand(time(0));
在循环内和循环外运行的结果不一样呢??
newer_zhk 2005-07-07
  • 打赏
  • 举报
回复
我把win-tc重装了下好了 可能不小心把什么删了
51365133 2005-07-07
  • 打赏
  • 举报
回复
不是scanf 和 printf函数
是getch();
newer_zhk 2005-07-07
  • 打赏
  • 举报
回复
#include <conio.h>和#include<stdio.h>其实都可以不用的 如果只有scanf printf之类的比较常用的函数的话

我觉得是编译器的问题 正在下dev c++
51365133 2005-07-07
  • 打赏
  • 举报
回复
dev c++ 我用的是它,但是编译中少了#include <conio.h>//<---少了吧

我加上后,没有问题了。
51365133 2005-07-07
  • 打赏
  • 举报
回复
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include <conio.h>//<---少了吧
void main()
{
unsigned long a[12],b[12],c[12],d[12],f[12],w[12],tmp[12];
int i;
for(i=0;i<11;i++)
{
srand(time(0));
w[i]=rand();
printf("%x\n",w[i]);
}
getch();
}

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧