当前位置: 代码迷 >> C语言 >> 求助 关于库函数stdlib.h
  详细解决方案

求助 关于库函数stdlib.h

热度:314   发布时间:2006-07-28 23:19:59.0
求助 关于库函数stdlib.h

请教各位C语言高手,小弟在用VC++6.0编C语言程序时用到了stdlib.h头文件中的函数randomize()和random(),可是VC不认识,总是报错,我在WIN-TC中编译过了,能通过,请问是什么问题,如果不能调用的话,那么在VC中编辑C程序如何表示随机数生成函数呢?先谢谢了!
下面是我的程序:
#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
void main()
{
int count,
number,
guess;
char yes='Y';
printf("\nNow let us play the game.\n Guess the number:");
while(toupper(yes)=='Y')
{
count=0;
randomize();
number=random(100)+1;
do{
do{
printf("\nInput an integer number(1-100):");
scanf("%d",&guess);
}while(!(guess>=1&&guess<=100));
if(guess<number)
printf("\nYour answer is LOW,try again.");
if(guess>number)
printf("\nYour answer is HIGH,try again.");
count++;
if(count==15)
{
printf("\nThis is the %d times!Think it hard next!");
exit(0);
}
}while(!(guess==number));
if(count<=7)
{
printf("\n You got it in &d times.\n",count);
printf("\n Congretulations!");
}
else
{
printf("\nYou got it in %d times.\n",count);
printf("\nI bet you can do it better");
}
printf("\n NEXT?(Y/N):");
scanf("%c",&yes);
}
}

搜索更多相关的解决方案: stdlib  函数  

----------------解决方案--------------------------------------------------------
咦..我记得是在TC下才不能识别randomize()的

难道我记错了

#include <time.h>
srand(time(NULL));


----------------解决方案--------------------------------------------------------

{}

不匹配


----------------解决方案--------------------------------------------------------