FILE MANIPULATION- OPEN,READ,WRITE

SOURCE CODE:
#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:
[examuser35@localhost Jebastin]$ cat>output1
a
b
c
[examuser35@localhost Jebastin]$ cat>output2
[examuser35@localhost Jebastin]$ cat>cc fileman.cc
[examuser35@localhost Jebastin]$ ./a.out
[examuser35@localhost Jebastin]$ cat>output2
a
b
c
Previous
Next Post »

If you still didn't find what you're looking for, you can search this website below: