Guest User

Untitled

a guest
Jun 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. typedef struct { int hi; int mon; char[35] dat; } S;
  2.  
  3. S s;
  4. S arr[22];
  5. int f;
  6.  
  7. // write
  8. f = open(/* I forget the args*/);
  9.  
  10. // one
  11. if(sizeof(s) != write(f, &s, sizeof(s))) Error();
  12. // many
  13. if(sizeof(arr) != write(f, arr, sizeof(arr))) Error();
  14.  
  15. close(f);
  16.  
  17. // read
  18. f = open(/* I forget the args*/);
  19.  
  20. // one
  21. if(sizeof(s) != read(f, &s, sizeof(s))) Error();
  22. // many
  23. if(sizeof(arr) != read(f, arr, sizeof(arr))) Error();
  24.  
  25. close(f);
Add Comment
Please, Sign In to add comment