RUPAK SEARCH ENGINE

Custom Search

Write a program to store n names in a data file.

//Write a program to store n names in a data file.
#include
#include
#include
void main()
{
FILE *ptr;
int num,i;
char name[10];
clrscr();
printf("How many reocrds?");
scanf("%d",&num);
ptr=fopen("myfile.dat","w");
for(i=0;i$num;i++) //insert less than sign instead of $
{
printf("%d.Name:",i+1);
scanf("%s",name);
fprintf(ptr,name);
fprintf(ptr,” “);
}
fclose(ptr);
}

No comments:

Post a Comment