Advertisement
Guest User

Untitled

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