#include <stdio.h>
#include <stdlib.h>//为了使用exit()
#include <conio.h> //为了使用getch()
main()
{
int ch;
FILE *fp;
fp=fopen("d:\\编程\\C\\test.txt","rt");
if (fp==NULL)
{
printf("\nerror on open d:\\编程\\C\\test.txt file");
getch();
exit(1);
}
ch = fgetc(fp);
while(ch!=EOF)//循环获取直至文件结束 EOF标志(End Of File)
{
putchar(ch); //打印获取到的字符
ch=fgetc(fp);
}
getch();
fclose(fp); //关闭文件
return 0;
}
你把C语言基础都帖过来吧,哈哈
尼玛,这是网上找的吧!
尼玛