1#include <stdio.h>2#include <stdlib.h>3 #define"Save.txt"4 intMainintargcintargv[])5 {6FILE *fp_read,*Fp_write;7 8Fp_read=fopen (The,"r+");9 Ten if(fp_read==NULL) One { APuts"Not exist,create now"); -Fp_write=fopen (The,"w+"); - if(fp_write==NULL) thePuts"Create failed"); - Else - { -Puts"Create succeed"); +Fputs"good\n", Fp_write);//Write file: Return non-negative value on success, EOF on Failure -Fflush (Fp_write);//storing data in a cache in a document +Fp_read=Fp_write; AFseek (Fp_write,0, Seek_set);//move cursor to end of file: Seek_end, beginning of file: Seek_set at - } - } - Else -Puts"Open succeed"); - in //Print File Contents -Rewind (Fp_read);//move the cursor to the beginning of the file to intCH =0; + while((Ch=fgetc (fp_read))! =EOF) - Putchar (CH); the *System"Pause"); $ Panax Notoginseng -}
File system: Read, file does not exist then create