#include<fcntl.h>//for open() write() read() close() system call...fcntl.h header file is used..//
#include<unistd.h>
int main()
{
char buff;
int count=1,fd,wfd;
fd=open("source1",O_RDONLY);//open system call is used to open 1st file in O_RDONLY MODE
wfd=open("desti",O_WRONLY|O_CREAT);//open system call is used to open another file in O_WRONLY MODE..//
while(count)
{
count=read(fd,&buff,1);//READ FROM 1ST FILE ONE BY ONE CHARACTER
write(wfd,&buff,1);//WRITE INTO 2ND FILE ONE BY ONE CHARACTER
}
//lseek(fd,22,SEEK_CUR);
//BCZ OUR AIM IS TO MERGE 2 FILES MEANS WE WILL READ FROM 1ST FILE WRITE INTO ANOTHER FILE ..THEN WE WILL READ FROM 2ND FILE ..& AGAIN WRITE INTO SAME ANOTHER FILE...//
fd=open("source2",O_RDONLY);//open another file to read//
count=1;
while(count)
{
count=read(fd,&buff,1);//READ FROM 2ND FILE
write(wfd,&buff,1);//WRITE INTO SAME ANOTHER FILE <DESTI>