C Program for reading data from a file

#include<stdio.h>

#include<conio.h>

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

Output

C Program for reading from a file

Published by

admin

I am a computer teacher, programmer and web developer