On Tue, Jul 12, 2005, Alon Altman wrote about "Strange C-code behavior with
pipes":
> When I compile this into a file called "prog" and then run: "./prog|cat" I
> see that "Hello" is not printed until I give it input. Where is the buffer
> here and
On Tue, 12 Jul 2005, Peter wrote:
add fflush(stdout); after printf. The buffer is related to the stream stdout.
You can turn it of using setvbuf() and friends. Don't do it if you don't have
to. The pipes are set up by the shell and may defeat what you are trying to
do with flush and setvbuf().
On Tue, 12 Jul 2005, Alon Altman wrote:
Hi,
I have some strange behavior of a C program.
The code is simple:
#include
int main(void)
{
char input[255];
printf("Hello\n");
gets(input);
return 0;
}
When I compile this into a file called "prog" and then run: "./prog|cat" I
see that "H
Hi,
I have some strange behavior of a C program.
The code is simple:
#include
int main(void)
{
char input[255];
printf("Hello\n");
gets(input);
return 0;
}
When I compile this into a file called "prog" and then run: "./prog|cat" I
see that "Hello" is not printed until I give it i