C program to copy contents of a file to another file
Program: #include<stdio.h> #include<fcntl.h> #include<sys/stat.h> int main(int argc, char * argv[]){ char block[1024]; int in,out,nread; in = open("t.txt",O_RDONLY); out = open("o.txt",O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR); if(in == -1 || out == -1){ printf("Unable to copy file\n"); return 0; } while((nread=read(in,block,1024)) > 0) write(out,block,nread); printf("File copied.\n"); close(in); close(out); return 0; }