帮忙看看这段程序有什么错误?#include "stdafx.h"#include#includevoid main(){\x05FILE *fp;\x05char *filename="test";\x05if((fp=fopen(filename,"r"))==NULL)\x05\x05printf("Cannot open the file!\n");\x05\x05else\x05\x05\x05printf("Open file se

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/30 12:13:16
帮忙看看这段程序有什么错误?#include

帮忙看看这段程序有什么错误?#include "stdafx.h"#include#includevoid main(){\x05FILE *fp;\x05char *filename="test";\x05if((fp=fopen(filename,"r"))==NULL)\x05\x05printf("Cannot open the file!\n");\x05\x05else\x05\x05\x05printf("Open file se
帮忙看看这段程序有什么错误?
#include "stdafx.h"
#include
#include
void main()
{
\x05FILE *fp;
\x05char *filename="test";
\x05if((fp=fopen(filename,"r"))==NULL)
\x05\x05printf("Cannot open the file!\n");
\x05\x05else
\x05\x05\x05printf("Open file seccess!\n");
\x05char ch=fgetc(fp);
\x05while(ch!=EOF)
\x05{
\x05\x05putchar(ch);
\x05\x05ch=fgetc(fp);
\x05}
\x05fclose(fp);
\x05getchar();
}

帮忙看看这段程序有什么错误?#include "stdafx.h"#include#includevoid main(){\x05FILE *fp;\x05char *filename="test";\x05if((fp=fopen(filename,"r"))==NULL)\x05\x05printf("Cannot open the file!\n");\x05\x05else\x05\x05\x05printf("Open file se
filename应该为文件的路径,fopen的第二个参数为r,代表 以只读方式打开文件且该文件必须存在.如下所示,其中c盘必须有test.txt这个文件,否则打开文件失败.还有,只有在打开文件成功的情况下,才有读取文件内容的操作.
void main(){FILE *fp;char *filename="C:/test.txt";if((fp=fopen(filename,"r"))==NULL)printf("Cannot open the file!\n");else{
printf("Open file seccess!\n");char ch=fgetc(fp);while(ch!=EOF){putchar(ch);ch=fgetc(fp);}fclose(fp);
}getchar();}