1

File reading synchronoulsy in linux c

view story
linux-howto

http://stackoverflow.com – Please see below code. #include < stdio.h > #include < fcntl.h > #include < stdlib.h > #include < string.h > int main(int argc,char **argv,char **envp) { int fd; size_t sz; char filebuffer[1024]; int loop; fd=open("sample",O_RDONLY); if(fd==-1) { perror(""); exit(1); } loop=0; while(++loop<300) { lseek(fd,0,SEEK_SET); memset(filebuffer,0,1024); sz=read(fd,filebuffer,1024); printf("%d.sz=%zd\t%s\n",loop,sz,filebuffer); sleep(1); } close(fd); return 0; } In this co (HowTos)