C Program for reading all data from a file

#include<stdio.h>

#include<conio.h>

int main()
{
FILE *fp;
int n1,n2,sum;
fp=fopen(“data.txt”,”r”);
while(feof(fp)==0)
{
fscanf(fp,”%d %d %d”,&n1,&n2,&sum);
printf(“n1 = %d n2 = %d sum = %d\n”,n1,n2,sum);
}
fclose(fp);
getch();
return 0;
}

Output

C Program for reading all data from a file

Published by

admin

I am a computer teacher, programmer and web developer