Advertisement
MAT4m

Untitled

Jan 13th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. struct person
  6. {
  7. int nr;
  8. char name[30];
  9. char surname[30];
  10. };
  11.  
  12. int main()
  13. {
  14.  
  15.  
  16. char p[20];
  17. struct person input;
  18.  
  19. FILE *inf;
  20. printf("name of the file\n");
  21. scanf("%s",p);
  22. inf=fopen(p,"r");
  23.  
  24. while(fread(&p, sizeof(struct person), 1, inf))
  25. printf ("id = %d name = %s %s\n", input.nr,input.name, input.surname);
  26. fclose(inf);
  27.  
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement