Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<sys/file.h>
- #include<sys/types.h>
- #include<sys/stat.h>
- #include<unistd.h>
- #include<stdio.h>
- int main()
- {
- char f1[30],f2[30],t[100];
- int fd,s1,s2;
- printf("Enter existing file name: ");
- scanf("%s",f1);
- printf("Enter new file name: ");
- scanf("%s",f2);
- fd=open(f1,O_RDONLY,S_IRUSR);
- if(fd==-1)
- return 1;
- s1=read(fd,t,100);
- close(fd);
- fd=creat(f2,S_IWUSR);
- s2=write(fd,t,s1);
- close(fd);
- if(s1==s2)
- printf("Size of both files= %d bytes\n",s1);
- else
- printf("Size mismatch\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement