Reading from stdin

Christian Vogel chris-usenet at hedonism.cx
Wed Mar 10 10:20:10 EST 2004


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

   Chris





More information about the Python-list mailing list