| Store | Cart

Reading from stdin

From: Christian Vogel <chri...@hedonism.cx>
Wed, 10 Mar 2004 16:20:10 +0100
C GIllespie wrote:
> efficient C program :). Actually, I would like to read-a-line/> print-a-line/ read-a-line/etc

probably both your C- and your python scripts use buffered output. So the
C-program will not print line-by-line but rather en-block after many bytes
of output have accumulated.

In your C-program, do this (that's most likely your problem):

        printf("%f\n",x); /* print valuable data */
        fflush(stdout);   /* make sure it's written to stdout */

In your python-program, do this (that's probably not your problem):

        print "%f"%x        # print valueable data
        sys.stdout.flush()  # make sure it's written to stdout


Recent Messages in this Thread
C GIllespie Mar 10, 2004 02:56 pm
Skip Montanaro Mar 10, 2004 03:14 pm
Christian Vogel Mar 10, 2004 03:20 pm
C GIllespie Mar 10, 2004 05:36 pm
P...@draigBrady.com Mar 11, 2004 11:03 am
Messages in this thread