august 发表于 2008-1-20 17:12:47

exit 的一点问题

#include<stdio.h>
void main()
{
    FILE *fp;
    char ch;
    if((fp=fopen("file.txt","w"))==NULL)
    {
      printf("can't open file.\n");
      exit(0);
    }
    while((ch=getchar())!='\n')
      fputc(ch,fp);
    fclose(fp);
}
像以上程序,它为什么总会报一个 'exit' undefinedassumingexternreturningint   的警告呢?

rednaxela 发表于 2008-1-21 05:14:26

LZ要指明用了什么什么环境和什么编译器.我用VC8的编译器编译没报exit的错.只有fopen相关的:
z.c(6) : warning C4996: 'fopen' was declared deprecated
      D:\\Program Files\\Microsoft Visual Studio 8\\VC\\include\\stdio.h(234) : see
declaration of 'fopen'
      Message: 'This function or variable may be unsafe. Consider using fopen_
s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help
for details.'

august 发表于 2008-1-21 08:10:04

是VC++6.0

lxhbs 发表于 2008-1-23 22:47:00

加一个#include<stdlib.h>
就不会警告了,至于什么原因,应该能猜出来了吧?
页: [1]
查看完整版本: exit 的一点问题