setvbuf is not working completely
Posted on 2005-04-14
i am working on
SunOS au1646s 5.8 Generic_117000-01 sun4u sparc SUNW,Sun-Fire-15000
i am working on different option of setvbuf function.
b = (char *)malloc(10);
p1 = fopen("1","w+");
printf("\n setting buffer result = %d\n",setvbuf(p1,c,_IOFBF, 8));
Now as per my understanding, after 1st fwrite, word "hllo" is still in buffer "c" and not gone to file "1", since buffer has not been filled completely to allocated size i.e. 8 bytes.
But 2nd fwrite completes this size and after call of 2nd fwrite, i should be able to see something in file "1".But i didn't find anything there.After call of fflush, i see "hllohllo" in file.Why?
2nd question: Since i am using my own buffer namely "c", i tried to print content of array "c" after call of fwrite, but i didn't find anything there.Why?