c语言文件读写

#include <stdio.h>
#include <stdlib.h>
void main()
{
     FILE *fp;
        char ch;
        if((fp=fopen("C:\\Users\\Administrator\\Desktop\\复件 demo01_考试题1.c","rt"))==NULL){
            printf("\nCannot open file strike any key exit!");
            getch();
            exit(1);
        }
        ch=fgetc(fp);
        while(ch!=EOF){
            putchar(ch);
            ch=fgetc(fp);
        }
        fclose(fp);
     system("pause");
}

你可能感兴趣的:(c语言文件读写)