/*user choice data*/
#include<stdio.h>
main()
{
char name[25];
int age;
FILE *fp;
fp=fopen("c.txt","a");
printf("Enter name and age of the student:");
while(scanf("%s%d",&name,&age)!=EOF)
{
fprintf(fp,"%s\t%d\n",name,age);
}
fclose(fp);
}
Note: Press CTRL + Z (^Z) if you want to stop data entry. It will automatically save into file