Rajorshi Biswas wrote:
> Hi all,
> I'm aware that this might not be a "C-specific" question, if so,
> please let me know which group is the most appropriate for this kind of
> question.
>
> This is a question on unix filehandling in C, all I have to do is
> rewind to the beginning of the file immediately after "write"ing some
> bytes. My code looks something like this -
>
> /* create a file and write something into it */
> int fd = open("test.txt", O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR);
open and friends are not part of standard C so you would do better
asking on comp.unix.programmer, however I would point out that if
O_WRONLY has the obvious meaning of opening the file for writing only
you will not be able to read from it.
<snip>
> while((nread = read(fd, block, sizeof(block))) > 0) /* READ FAILS
> HERE <<< */
<snip>
If you want further information on using open and friends, please ask in
comp.unix.programmer
--
Flash Gordon, living in interesting times.
Web site -
http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc