Hi all,
while drafting another man page I tried to find out, what the following
sequence would return (given that the file exists and is not empty):
fp = fopen("data", "a+");
c = fgetc(fp);
While it seems clear, that a write does an implicit seek to the current
end-of-file, I couldn't find out, what the read pointer is expected to be
just after the file has been opened. Looking at the open() man page
reveals that an open(..., O_APPEND | O_RDWR) is expected (as any open) to
place the file pointer at the begin of the file so that:
fd = open("data", O_RDWR | O_APPEND);
read(fd, &c, 1);
would return the first byte of the file.
It seems to me, that it is sensible to expect the same behaviour from
fopen() (and fdopen() for that case).
Should this be corrected (probably by adapting the corresponding paragraph
from open())?
Regards,
harti
--
harti brandt,
http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private
yyyyyy@xxxxxxxxxxxxxxxxxxx, yyyyy@xxxxxxxxxxx
|