How to Read Data from File in C Programming
Get Certified in C Programming and Take Your Skills to the Next Level
Program 1
// Program for read data from file
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp=NULL;
char ch;
int csp=0,cc=0,cl=0;
fp=fopen("e://cdata/employee.txt","r"); // Read mode
if(fp==NULL) //check file
printf("\nFile not open....\n");
else
{
do
{
ch=fgetc(fp);
printf( “%c,ch”);
}while(ch!=EOF);
fclose(fp);
}
Did you like this article? If Yes, please give DataFlair 5 Stars on Google

