将文件中的字符显示在屏幕上
#include "stdio.h"#define ERROR 0
main()
{
FILE *fp;
char ch;
printf("以下显示的便是该程序的源代码!\n");
if ((fp=fopen("c:\myfile.c","r"))==NULL)
{
printf("Can't open the file and press any key to exit\n");
getchar();
return ERROR;
}
ch=fgetc(fp);
while(ch!=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
printf("\n");
}