I am trying to learn C and gtk+ 2.0 and I just wrote a simple program that puts a text file to stdout when a button is pushed.
For some reason, the output from the file leaves an extra line in the stdout buffer, such that if you press the button again, this extra line (composed of those wierd merge-sign like characters) appears before the file content (ie, it is the first line in the buffer). Obviously, if I __fpurge(stdout) first (or at the end of the last call), then everything is fine.
However, a non-gtk version of the same thing does not leave this extra line and so doesn't require flushing. Does anyone know why? Note that if I use "g_print" instead of "printf" an extra line appears at the end of the output instead of being kept in the stdout buffer (it looks like a different line than the other one too).
Also: is there not a portable, ANSI version of __fpurge? Or are you suppose to redirect fflush for unwanted stdout contents?