File Manipulation Programming Algorithm in UNIX Linux lap program

Source code File Manipulation Programming Algorithm
#include<stdio.h>
#include<unistd.h>
int main()
{
int fd_in,fd_out,n bytes;
char buf[512];
fd_in=open(“output 1”,0);
fd__creat(“output 2”,0644);
n bytes=read(fd_in,buf,512);
while (n bytes>0)
{
write(fd_out,buf,n bytes);
n bytes=read(fd_in,buf,512);
}
close(fd_in);
return 0;
}


OUTPUT CS1252 Operating Systems lap
[redhat35@localhost Rhel5]$ cat>output1
a
b
c
[redhat35@localhost Rhel5]$ cat>output2
[redhat35@localhost Rhel5]$ cat>cc fileman.cc
[redhat35@localhost Rhel5]$ ./a.out
[redhat35@localhost Rhel5]$ cat>output2
a
b
c

Related post