C Program to store information about a person in a file

C Program to create a file emp.txt and store information about a person, in terms if his name, age and salary.

#include<stdio.h>
int main(){
char name[20];
int age;
float salary;
FILE *fp;
fp=fopen("emp.txt","w+");
printf("enter name");
scanf("%s",&name);
printf("enter age");
scanf("%d",&age);
printf("Enter salary");
scanf("%f",&salary);
fprintf(fp,"%s %d %f",name,age,salary);

printf("\n \n");
fscanf(fp,"%s %d %f",name,age,salary);
printf("Name=:-%s\nAge:-%d\nSalary:-%f\n",name,age,salary);

return 0;
}

 

Output