//read this section of the file to get command line arguments to read intch; FILE*FP; unsignedLongCount =0; if(argc!=2) {printf ("no parameters \ n"); Exit (Exit_failure); } if((Fp=fopen (argv[1],"R"))==NULL) {printf ("file has no content \ n"); Exit (Exit_failure); } while((CH=GETC (fp))! =EOF) {PUTC (ch,stdout); //It 's the same meaning as the sentence.//Putchar (CH);count++; } fclose (FP); printf ("\ n"); printf ("file%s has%lu characters \ n", argv[1],count); //Write to File Char*s="That ' s good news";/*defines a string pointer and initializes*/ intI=617;/*defining an Integer variable and initializing it*/FILE*FP;/*Defining file Pointers*/FP=fopen ("Test.dat","W");/*Create a text file to write only*/fputs ("Your score of Toeflis", FP);/*write a string of characters to the file you built*/FPUTC (':', FP);/*write a colon to the file you built:*/fprintf (FP,"%d/n"+ N);/*write an integer number to the file you have built*/fprintf (FP,"%s", s);/*write a string to the file you built*/fclose (FP); /*Close File*/
C Language file reading and writing