/* Pro129B.c */ /* How to write an external file automatically? */ /* Please use fopen( , "w") at write-mode and fprintf(). */ #include<stdio.h> #include<string.h> char inline [100]; int main(void) { FILE *infp, *outfp; infp = fopen("Infile.txt", "r"); /* File pointer infp opens "infile.txt" as "r"(read) */ outfp= fopen("Outfile.txt", "w"); /* File pointer outfp opens "outfile.txt" as "w"(write) */ while(fgets(inline, 100, infp)!=NULL){ /* Start reading one line each time */ printf(inline); /* For screen monitor */ fprintf(outfp, "%s", inline); /* Echo writing out one line each */ } /* time into "Outfile.txt. */ fclose(infp); fclose(outfp); return 0; }