Previous | Home | Next |
Once The file has been opened for reading using fopen() function. The file’s contents are brought into memory and a pointer points to the very first character. To read the file’s contents from memory there exists a function called fgetc() .
A simple program to Read a file
#include<stdio.h> void main() { FILE *fp1; char a; if ((fp1=fopen("myfile.txt","r"))==NULL) printf("this file does not exist\n"); else { while((a==fgetc(fp1))!EOF) printf("%c",a); } }
Output:I am ashish kumar gupta. I have completed MCA from ajay kumar garg engg. college gzb.
Previous | Home | Next |