when to fflush ?
Siva Chelliah
siva at bally.Bally.COM
Fri Jun 14 01:51:36 AEST 1991
Hi,
I have a question. Does seeking to the end of a file causes a flushing
of the buffer ? In my opinion it should not.
Look at the following program. Even though I write only 5 bytes,
when you do a cat on test.out , you see "hello." Move the sleep(500)
before fseek , and you won't see it. It happened on both IBM RT running
AIX 2.1 and RS 6000 running AIX 3.1. Please comment.
Thanks ,
Siva
-------------------------------
#include <stdio.h>
main ()
{
FILE *fp;
char buf[80];
strcpy(buf,"hello\n");
system ("touch test.out"); /* just to create the file */
fp = fopen ("test.out","r+");
fseek(fp,0L,0); /* seek to start of file - you do not need this */
fwrite(buf,strlen(buf),1,fp);
fseek(fp,0L,2); /* seek to end of file */
sleep(500);
fclose (fp);
}
--
/=*=*=*=*=*=*=*=*=*=*=*=*=*=*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\
| Siva at bally.bally.com | He who asks is a fool for five minuites,|
| Bally Systems, | but he who does not ask remains a fool |
| Reno, NV 89502 | forever -Old Chinese saying |
More information about the Comp.unix.aix
mailing list