有关C语言的一个问题,请大家看看

来源:百度知道 编辑:UC知道 时间:2024/05/28 09:35:35
这个程序我在TC里面可以编译通过..可是在visual c++ 6.0里面编译的时候却报错了!请各位帮我看看
#include <stdio.h>
#include <time.h>
main()
{
clock_t start,end;
int n;
printf("How many seconds do you want to count? ");
scanf("%d",&n);
getchar();
clrscr();
start=end=clock();
while((n-(int)(end-start)/19)>=0&!kbhit())
{
printf("the time is: %d",n-(int)(end-start)/19);
sleep(1);
end=clock();
clrscr();
}
printf("fuck you");
sleep(3);
clrscr();
}
头文件包含的问题
vc++里面的stdio.h和time.h与tc的不一样了

我知道这个..请问我在VC++里面编译C语言..而且文件也是C语言的,,难道也要改头文件吗...请问怎么改..麻烦您了高手

这是程序代码,我改好了你看看吧 希望你有所收益

#include <stdio.h>
#include <time.h>
#include <conio.h>
#include <windows.h>
void main()
{
clock_t start,end;
int n;
printf("How many seconds do you want to count? ");
scanf("%d",&n);
getchar();
system("cls");
start=end=clock();
while((n-(int)(end-start)/19)>=0&&!kbhit())
{
printf("the time is: %d",n-(int)(end-start)/19);
Sleep(1);
end=clock();
system("cls");
}
printf("fuck you");
Sleep(3);
system("cls");
}

头文件包含的问题
vc++里面的stdio.h和time.h与tc的不一样了

其实你看那里报错,也就能看出来那里错了啊!
就知道是哪个文件找不到了啊

1.不能只写main(),要写void main()
2.kbhit()函数需要包含conio.h
3.VC没有clrscr()函数,请用System("cls")
4.VC中的暂停函数是Sleep(毫秒数)
5.System和Sleep请包含<windows.h>以提供