[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ProgSoc] I can't get smoke out of my pipe
On Sun, 3 May 1998, email@example.com wrote:
> Can anybody explain why the following simple program does not work:
[ code snipped ]
fprintf writes to a buffer, which is only written to the stream when the
buffer is flushed. Using "close" does not flush the buffer, so that is
why s appears empty.
You'll either want to use fflush(b) - to make sure "foo foo foo \n" is
written to the stream before you read from it, or use "fclose(b)", which
flushes the buffer before closing the stream.
> write(p,"ZXCZXCZXCZXC", 10);
> This time, lo and behold, it worked. Can someone explain why the original
> program does not work?
"write" writes directly to your pipe... no buffer involved
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to firstname.lastname@example.org.
If you are having trouble, ask email@example.com for help.
This list is archived at <http://www.progsoc.uts.edu.au/lists/progsoc/>