Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. typedef struct prisoner{
  6. int trackNumber;
  7. char password[100];
  8. char time[100];
  9. char date[100];
  10. char cell[100];
  11. int lenOfPunish;
  12. }Prisoner;
  13. struct emp
  14. {
  15. char name[15];
  16. int age;
  17. int salary;
  18. char address[30];
  19. }EMP;
  20. typedef struct person
  21. {
  22. int id;
  23. char fname[20];
  24. char lname[20];
  25. }Person;
  26. int main()
  27. {
  28. Prisoner pris;
  29. Prisoner pris1;
  30. Person person,per1;
  31.  
  32. person.id = 10;
  33. strcpy(person.fname, "Kosta");
  34. strcpy(person.lname, "Kesic");
  35.  
  36. FILE *fp;
  37. FILE *fpopen;
  38. fp = fopen("novi.txt","w");
  39. fwrite(&person, sizeof(Person),1,fp);
  40. fclose(fp);
  41. fpopen = fopen("novi.txt", "r");
  42. fread(&per1, sizeof(Person),1,fpopen);
  43. printf("%d %s %s", per1.id, per1.fname, per1.lname);
  44. fclose(fpopen);
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement