Mail Archives: djgpp/1997/07/02/20:07:45
Justin Talbot wrote:
>
> Two problems:
>
> First if I compile and run a simple program:
> void main(void)
That is incorrect. main() must return an integer according to the ANSI
standard. Declaring it as void may cause undefined behavior.
> {
> printf("Hello world");
> getch();
> }
stdio and conio functions use the screen and console differently.
stdout is line-buffered, so you don't see anything on the screen until
you 1) print a newline, 2) call fflush( stdout ), 3) use a stdio input
function, 4) the internal buffer overflows.
Since getch() is a conio function, it does not invoke rule 3.
--
---------------------------------------------------------------------
| John M. Aldrich | "Money is truthful. If a man speaks |
| aka Fighteer I | of his honor, make him pay cash." |
| mailto:fighteer AT cs DOT com | |
| http://www.cs.com/fighteer | - Lazarus Long |
---------------------------------------------------------------------
- Raw text -