1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include<unistd.h>
#include<stdlib.h>
#include<fcntl.h>
#include<sys/types.h>
#include<stdio.h>
int main() {
char block[106];
int op,in;
int rdbyte;
op=open("files.out1",O_RDWR|O_CREAT,S_IRUSR|S_IWUSR|S_IXUSR|S_IROTH|S_IWOTH|S_IXOTH);
if (op==-1)
write(1,"some error\n",11);
rdbyte=write(op,"Hello world! This is CodeZer0.I love using linux specially BackTrack4.I am concentrating on c programming\n",106);
if (rdbyte==0)
write(1,"data not written\n",17);
in=open("files.in",O_RDWR|O_CREAT,S_IRUSR|S_IWUSR|S_IXUSR|S_IROTH|S_IWOTH|S_IXOTH);
if (in==-1)
write(1,"some error in files.in\n",23);
printf("%d\n",op);
rdbyte=read(op,block,106);
if (rdbyte==0)
write(1,"data not read\n",14);
if (rdbyte==-1)
write(1,"some error\n",11);
rdbyte=write(in,block,106);
if (rdbyte==0);
write(1,"data not entered\n",17);
if (rdbyte==-1)
write(1,"some error2\n",15);
return 0;
}
|