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 »

Still not found what you are looking for? Try again here.