【帮帮我啊!】读取文件程序总是出错!
kgbcn 2007-06-25 12:26:39 本人编写了一个读取文本文件内容的练习小程序,代码如下:
#include "iostream.h"
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
void main()
{
FILE *fp;
fp=NULL;
if((fp=fopen("c:\\data.txt file","r"))==NULL)
cout<<"文件读取正确";
else
exit(0);
char ch=fgetc(fp);
while(ch!=EOF) //用来循环读取文件的内容。
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
}
可以编译通过,可是程序一运行,就出现如下错误:
Debug Assertion Failed!
Program: c:\1.exe
File:fgetc.c
Line:41
Expression:stream!=NULL
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
这到底是那里出错了啊?
帮帮我啊?