C Programming
#include
#include
void main()
{
clrscr();
FILE *fp;
char *name,*roll,*gpa;
int i;
fp=fopen("c:\\information.dau","w");
for(i=0;i<2;i++)
{
printf("Enter the information of student number[%d]",i+1);
gets(name);gets(roll);gets(gpa);
fprintf(fp,"%20s %20s %5s\n",name,roll,gpa);
}
fclose(fp);
fp=fopen("c:\\information.dau","r");
while((fscanf(fp,"%20s %20s %5s",name,roll,gpa))!=EOF)
{
printf("%20s %20s %5s\n",name,roll,gpa);
}
fclose(fp);
getch();
}
0 comments:
Post a Comment