Friday, April 10, 2015

20. Write a program to reading a data file.

#include<stdio.h>
#include<conio.h>
 struct student
{
char name[30];
int roll,age;
}s;

void main()
{
FILE *ptr;
clrscr();
ptr=fopen("record,txt","r");
printf("\n Name \t Roll \t Age");
while(fread(&s,sizeof(s),1,ptr==1))
  printf("\n%s \t %d \t %d",s.name,s.roll,s.age);
fclose(ptr);
getch();
}

No comments:

Post a Comment