C Programming language

C - File Operation : Read a File
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

void main()
	FILE *fp1;
	char a;
	if ((fp1=fopen("myfile.txt","r"))==NULL)
		printf("this file does not exist\n");

Output:I am ashish kumar gupta. I have completed MCA from ajay kumar garg engg. college gzb.

Previous Home Next