hi, I need to know how to lock a file. I used the following code, but after executing the program the file 'write.txt' remined empty, and I have no idea why.Maybe I'm not using the corresponding syntax for blocking a file. But I deleted then the blocking part and the problem persisted.
see to code:
......
f=open("read.txt",O_RDONLY);
fcntl(f,F_SETLK);
read(f,buffer,sizeof(buffer));
g=open("write.txt",O_WRONLY);
write(g,buffer,sizeof(buffer));
close(g);
fcntl(f,F_UNLCK);
close(f);
.......
then I tried to replace open with fopen (so I use FILE *g of course, and fprintf()) but still nothing was in that file(write.txt).So I have no clue. If you got sometime pls say somethin'. I need to do this as soon as I can. You are welcomed to say somethin' smart
10x