文件操作 CPU遇到无效指令
#include<stdio.h>void open()
{FILE *in;
if((in=fopen("stu.dat","rb"))==NULL)
printf("not exist\n");
fclose(in);
}
void main()
{
open();
getch();
}
这个简单的函数,哪里出错了呢,就是文件不存在的话 if 后面的 not exist不是应该显示么,但是为什么不显示呢。
2011-05-12 22:32

2011-05-12 23:00
2011-05-13 00:01
程序代码:#include<stdio.h>
#include <conio.h>
void open()
{
FILE *in;
if((in=fopen("stu.dat","rb"))==NULL)
{
printf("not exist\n");
return;
}
fclose(in);
}
void main()
{
open();
getch();
}
2011-05-13 08:16
程序代码:#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void open(void)
{
FILE *in;
if((in=fopen("stu.dat","rb"))==NULL)
{
printf("not exist\n");
exit(0);
}
fclose(in);
}
void main()
{
open();
getch();
}
2011-05-13 08:17
2011-05-13 11:35
2011-05-13 11:51
2011-05-13 11:51
2011-05-13 11:56
2011-05-13 12:09