Mail Archives: djgpp/1997/11/12/20:22:37
At 04:36 11/12/1997 GMT, Ashod wrote:
>
>I recently wrote this.
>
>void main (void)
>{
>printf("\nHello");
>getch();
>}
>
>
>// but it did it the wrong way round.... it displayed hello after I hit a
>key,
>any thoughts on this ??
stdio functions are buffered. The output is not done until you write a
newline ('\n') or call fflush() on the stream. Also, intermixing stdio
functions (printf, scanf) and conio functions (getch, cprintf) can lead to
trouble. FAQ section 9.4 has more.
(And yes, as someone pointed out, `void main' is incorrect according to ANSI
and can lead to problems on some machines. You should always use `int main'
and return 0 under normal conditions.)
Nate Eldredge
eldredge AT ap DOT net
- Raw text -