Oct 4, 2011

C program to illustrate as to how the data stored on the disk is read.

C Program to illustrate as to how the data stored on the disk is read. In this program we use the C File i/o operations to read the file from disk. fopen function open the files for reading, and fclose() closes the file. Read more about C Programming Language .

* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*                                  Happy Coding

#include <stdio.h>
#include <stdlib.h>

void main()
 FILE *fptr;
 char filename[15];
 char ch;

 printf("Enter the filename to be opened\n");

 fptr = fopen (filename, "r");  /*open for reading*/

 if (fptr == NULL)
  printf("Cannot open file\n");

 ch = fgetc(fptr);

 while (ch != EOF)
  printf ("%c", ch);
  ch = fgetc(fptr);

}        /* End of main () */
Read more Similar C Programs
C Basic

C File i/o
You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!