linux下,
#include <stdio.h>
#include <errno.h>
void main()
{
FILE *fp;
fp = fopen("./2222.txt", "r");
printf("%d", errno);
if (fp == NULL)
printf("file not open");
fclose(fp);
}
如果文件不存在, 在运行的时候出现段错误。
怎么才能让这个程序运行,并执行第二行,主要想看看错误号。
#include <stdio.h>
#include <errno.h>
void main()
{
FILE *fp;
fp = fopen("./2222.txt", "r");
printf("%d", errno);
if (fp == NULL)
printf("file not open");
fclose(fp);
}
如果文件不存在, 在运行的时候出现段错误。
怎么才能让这个程序运行,并执行第二行,主要想看看错误号。
解决方案 »
- 多文档下视图最大化和窗口时菜单有什么不同
- 开发一个基于Internet的收费软件,用Socket编程,发送收费数据,有些疑问,盼解答!
- 新安装的VC怎么新建工程里面没有MFC向导?
- 多处理器的Windows操作系统下如何查询特定CPU的即时信息?
- 截至 20040420 CSDN论坛三星级用户名单
- 寻找共享软件合作开发伙伴
- 改行学C#去了,劝各位仁兄也不要再学mfc了
- listCtrl 在Win7触摸屏中,横向手势的设置问题
- 怎样在程序中设置默认纸张方向
- 如何在vc中做向vb那样的activex控件,既该控件是个form或frame,我可以在上面加我需要的多个控件
- 这段代码能在C++中运行不?
- 100分求msdn6。0下载地址!!!
#include <errno.h>
void main()
{
FILE *fp;
fp = fopen("./2222.txt", "r");
printf("%d", errno);
if (fp == NULL)
printf("file not open");
else
fclose(fp);
}不行吗?
fclose(fp);不一样
可能错误是fclose(NULL)引起的罢
fclose(fp);不一样
可能错误是fclose(NULL)引起的罢?????第二行打印错误号都没有打印出来, 怎么下面的程序能影响呢。。
{}
catch(...)
{}