Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <sys/wait.h>
  4. #include <unistd.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #include <fcntl.h>
  9.  
  10.  
  11. int main() {
  12. int file1=open("file1",O_RDONLY);
  13. printf("Opening for write!!!!");
  14. int file2=open("file2",O_WRONLY);
  15.  
  16. int i=1;
  17. if (i>1)
  18. if (i<=100)
  19. i++;
  20. write(file2,&i,sizeof(int));
  21. read(file1,&i,sizeof(int));
  22. printf("%d\n\t",i);
  23. close(file1);
  24. close(file2);
  25.  
  26. return 0;
  27. }
  28.  
  29. ~
  30. ~
  31.  
  32. #include <sys/types.h>
  33. #include <sys/stat.h>
  34. #include <sys/wait.h>
  35. #include <unistd.h>
  36. #include <stdio.h>
  37. #include <string.h>
  38. #include <stdlib.h>
  39. #include <fcntl.h>
  40.  
  41.  
  42. int main() {
  43. int file1=open("file1",O_RDONLY);
  44. printf("Opening for write!!!!");
  45. int file2=open("file2",O_WRONLY);
  46.  
  47. int i=1;
  48. if (i>1)
  49. if (i<=100)
  50. i++;
  51. write(file2,&i,sizeof(int));
  52. read(file1,&i,sizeof(int));
  53. printf("%d\n\t",i);
  54. close(file1);
  55. close(file2);
  56.  
  57. return 0;
  58. }
  59.  
  60. ~
  61. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement