Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [1]
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/wait.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <fcntl.h>
- int main() {
- int file1=open("file1",O_RDONLY);
- printf("Opening for write!!!!");
- int file2=open("file2",O_WRONLY);
- int i=1;
- if (i>1)
- if (i<=100)
- i++;
- write(file2,&i,sizeof(int));
- read(file1,&i,sizeof(int));
- printf("%d\n\t",i);
- close(file1);
- close(file2);
- return 0;
- }
- [2]
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/wait.h>
- #include <unistd.h>
- #include <stdio.h>
- #include<string.h>
- #include <stdlib.h>
- #include <fcntl.h>
- int main()
- {
- printf("Opening for read!!!");
- int file2=open("file2",O_RDONLY);
- int file1=open("file1",O_WRONLY);
- int i;
- read(file2,&i,sizeof(int));
- if (i<=100)
- i++;
- write(file1,&i,sizeof(int));
- printf("%d\n\t",i);
- close(file1);
- close(file2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement