Reading Records from File

Let us now write a program that reads the employee records created by the above program. Here is how it can be done…

/* Read records from a file using structure */
#include "stdio.h"
int main() 
	FILE *fp;
	struct emp 
		char name[40];
		int age;
		float bs;
	struct emp e;
	fp = fopen("targetfile.txt", "r");
	if (fp == NULL) 
		puts("Cannot open file");
	while (fscanf(fp, "%s %d %f",, &e.age, & != EOF)
		printf("\n%s %d %f",, e.age,;
	return 0;