[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 7.286::atarist

Title:Atari ST, TT, & Falcon
Notice:Please read note 1.0 and its replies before posting!
Moderator:FUNYET::ANDERSON
Created:Mon Apr 04 1988
Last Modified:Tue May 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1433
Total number of notes:10312

624.0. "printf on MWC" by MVSUPP::RYMER (Stealthy is Healthy) Tue Oct 03 1989 14:29

Hi,



I'm not sure how to duplicate this but, sometimes, when you use the printf
function under MWC on the atari, it appears to buffer the output data before
it is displayed on the screen. This causes weird problems when trying to 
trace a problem, because your printf's are not output immediately, hence you
may be in a different function when the data is output.

It may be a result of using Cconws and printf in the same program, but i'm
not sure. Any help would be greatly appreciated.


Thanks in advance,


	Andy.
T.RTitleUserPersonal
Name
DateLines
624.1MWC buffers output to stdoutOLDTMR::WALLACETue Oct 03 1989 14:5433
    Yes MWC does buffer the output of a printf. You can cause the output
    buffer to be flushed (ie:send buffer to screen) in any one of the
    following ways -
    	1 - Calling getc() or scanf() will "flush" the buffer.
    	2 - A \n (newline) in the output stream (string) will flush the
    	    buffer.
    	3 - Calling fflush(stdout) will flush the buffer. (I don't guarantee
    	    thats the correct function name and syntax, but I believe it
    	    is. stdout is defined in stdio.h)
    
    Soooo, prompting for input works ok -
    	printf( "Hit return when ready. " );
    	getc( );
    
    Outputing informational messages (ie:status and debug information)
    works IF you get used to putting your \n at the end of strings and not
    the beginning of strings -
    	printf( "First call\n" );
    	Call_1( );
    	printf( "Second call\n" );
    	Call_2( );
    
    Outputing multiple strings on one line MUST have a call to fflush() (or
    whatever the actual name of the function is) -
    	printf( "Sector count - ");
    	for( i = 1; i < 9; i++ ) {
          format( i );
    	  printf( "%d ", i );
    	  fflush( stdout );
    	}
    
    Hope this helped,
    	Ray
624.2PRNSYS::LOMICKAJJeff LomickaTue Oct 03 1989 14:583
I can confirm that "fflush( stdout)" is the correct function name.  Be
sure to "#include <stdio.h>".