#include<stdio.h>
#include<conio.h>
struct
{
int roll;
char name[25];
float mark;
}std;
{
int n,i;
FILE *fp;
fp=fopen("d:\\cprg\student.txt","w");
clrscr();
printf("\n Enter how many records: ");
scanf("%d",&n);
printf("enter student number name and marks for %d students",n);
for(i=0;i<n;i++)
{
scanf("%d%s%f",&std.roll,std.name,&std.mark);
fprintf(fp,"%d\t%s\t%f\n",std.roll,std.name,std.mark);
}
fclose(fp);
fp=fopen("d:\\cprg\student.txt","r");
printf("\nRoll\tName\tMarks Obtained\n");
while(fscanf(fp,"%d%s%f",&std.roll,std.name,&std.mark)!=EOF)
printf("%d\t%s\t%f\n",std.roll,std.name,std.mark);
fclose(fp);
getch();
}
No comments:
Post a Comment
Rahul-Notes