File Operations in C Language -- display the content of the output text file on the screen
// Output of text files
/*
========================================================== ======================================
Question: The content in the output text file is displayed on the screen!
========================================================== ======================================
*/
# Include
# Include
Void main ()
{
FILE * fp;
Char ch;
Fp = fopen (D: data.txt, r );
If (fp = NULL)
Printf (can not open! );
Else
{
Fscanf (fp, % c, & ch );
While (! Feof (fp ))
{
Putchar (ch );
Fscanf (fp, % c, & ch );
}
Fclose (fp );
}
Printf ();
}
/*
========================================================== ======================================
Rating:
Read characters: fscanf (fp, % c, & ch), ch = fgetc (fp );
========================================================== ======================================
*/