Mail Archives: djgpp/1995/11/13/04:45:21
"J. A. McNamara" <grulm AT netaxs DOT com> wrote:-
> I find that when I do a printf, or putchar, nothing appears on the screen
> until I send a "\n" to standard output ... So, is there any way to force the
> buffer to flush to standard output without a newline?
fflush(stdout);
Also, in Gnu C/C++ stdout's buffer is automatically flushed when anything is
read from stdin (usually = from the keyboard), so these will work:-
printf("name of experiment?"); gets(exptname);
double ask(char*s) {double x; char buf[512];
X: printf(s); gets(buf); if(sscanf(buf,"%lf",&x)<1) goto X; return x;}
...
weight=ask("weight of sample?");
- Raw text -