I have always felt that the part of the file stream in the book is more ugly than A Dream of Red Mansions. I have never understood this problem for almost two years. Today, we have finally solved a part of the problem. It is indeed a leap in terms of "quality.
/*
I want to write a program to read and output the file content to the display and save the file content to a file named Zhaos. renye file (in Linux, the suffix does not matter ). Start to implement
*/
# Include <iostream. h> 〉
# Include
Int main (){
File * FP, * Zhaos:
// Open the file
Fp = fopen ("a.txt", "R "):
If (FP = NULL)
{
Printf ("file open erroe! \ N "); exit (0 );
}
Char C;
While (1)
{
C = fgetc (FP); putc (C, FP );
} Fcloese (FP); fcloese (Zhaos );
Return 0:
}// Open the Zhaos file to display the content of the FP file. //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ///////////////////// The following output specific content is saved to a file.
# Include <stdio. h> int main () {file * FP; FP = open ("zhoas.txt", "W"); If (! FP) {printf ("Open error! "); Exit) (0);} int I; for (I = 0; I <10000; I ++) fprintf (FP," % d \ n ", i); fclose (FP); Return 0;} // click here to open the zhaos.txt file, which is 1 ~ All numbers of 10000