[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, vlrajews@nospam.acs.itd.uts.edu.au 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[1],"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
-yap
--
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to progsoc-request@nospam.progsoc.uts.edu.au.
If you are having trouble, ask owner-progsoc@nospam.progsoc.uts.edu.au for help.
This list is archived at <http://www.progsoc.uts.edu.au/lists/progsoc/>