Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Display Record From Text File
- #include<conio.h>
- #include<stdio.h>
- typedef struct student
- {
- int roll, mark;
- char name;
- }stud;
- void main()
- {
- stud stud;
- FILE *fp;
- //int found = 0, find;
- clrscr();
- fp=fopen("stud1.txt","r");
- if(fp==NULL)
- {
- printf("\n File Opening Error");
- //exit(1);
- }
- while(1)
- {
- fscanf(fp,"%d\t%s\t%d\n", &stud.roll, stud.name, &stud.mark);
- //if(stud.roll==find)
- //{
- //found = 1;
- printf("\n Details Found");
- printf("\n Roll : %d", stud.roll);
- printf("\n Name : %s", stud.name);
- printf("\n Marks : %d", stud.mark);
- //}
- if(feof(fp))
- {
- break;
- }
- }
- fclose(fp);
- getch();
- }
Add Comment
Please, Sign In to add comment