Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #pragma pack(1)
  5.  
  6. typedef struct
  7. {
  8. char nume_localitate[17];
  9. int nr_angajati;
  10. }FIRMA;
  11. #pragma pack()
  12.  
  13. int main()
  14. {
  15.  
  16. FIRMA p;
  17. FILE *f;
  18.  
  19. if((f = fopen("exper.txt","rb")) == NULL)
  20. {
  21. printf("EROARE");
  22. exit(EXIT_FAILURE);
  23. }
  24.  
  25. while(!feof(f))
  26. {
  27. fread(&p,sizeof(FIRMA),1,f);
  28. printf("%2s %d\n",p.nume_localitate,p.nr_angajati);
  29. }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement