1、 C Chapter 24.Chapter 24-1.C .fopen FILE fopen FILE FILE !fopen fopen FILE .FILE .FILE .fopen .wt .fp data.txt .rt .fp data.txt .A fp !data.txt.!FILE*fp=fopen(C:Projectdata.txt,wt);fopen .fclose fclost .fclose Ch21 fflush fflush .fflush .fflush .fflush fclose .?.fp ch!Chapter 24-2.C .!1?2?(Basic)1:R
2、ead or WriteQ +,.Q a .R/W .2:,(t):(b):.:-Windows -:,:-.-:,!rwar+w+a+btRead or Write Binary or Textrbwta+t t b 1text.txt n?C n .C n.2text.txt n n .n?Windows rn Linuxn Macr 3 .Chapter 24-3.C Chapter 21 stream stdin stdout ,FILE .int fputc(int c,FILE*stream);/int fgetc(FILE*stream);/int fputs(const cha
3、r*s,FILE*stream);/char*fgets(char*s,int n,FILE*stream);/A B fp fp .n .n .n readn readwrite read!feof .EOF.EOF .EOF .feof EOF !EOF .feof EOF !:freadint main(void)int buf12;.fread(void*)buf,sizeof(int),12,fp);.sizeof(int)12 fp buf!:fwriteint main(void)int buf7=1,2,3,4,5,6,7;.fwrite(void*)buf,sizeof(in
4、t),7,fp);.sizeof(int)7 buf fp!buf !feof !1.2.1.2.Chapter 24-4.C :fprintf,fscanffprintf printf .fp ().sprintf printf .fp .fprintf&?fscanf&?fprintf&fscanf !Text/Binary .fread&fwrite .Chapter 24-5.C?FILE .read :“?”write :“?”,Read/Write .fputs,fread,fwrite .:fseek fseek fseek 1 2 3 4 5 6 7 8 9 e(eof)1 2 3 4 5 6 7 8 9 e(eof)1 2 3 4 5 6 7 8 9 e(eof)1 2 3 4 5 6 7 8 9 e(eof)1 2 3 4 5 6 7 8 9 e(eof)1 2 3 4 5 6 7 8 9 e(eof)?:ftell !Chapter 24.?