找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2945|回复: 3

[通用编程] exit 的一点问题

[复制链接]
发表于 2008-1-20 17:12:47 | 显示全部楼层 |阅读模式
#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' undefined  assuming  extern  returning  int   的警告呢?[s:3]
发表于 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.'
 楼主| 发表于 2008-1-21 08:10:04 | 显示全部楼层
是VC++6.0 [s:7]
发表于 2008-1-23 22:47:00 | 显示全部楼层
加一个  #include<stdlib.h>
就不会警告了,至于什么原因,应该能猜出来了吧?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|幻想森林

GMT+8, 2026-11-6 17:25 , Processed in 0.010230 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表