delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/12/20:22:37

Date: Wed, 12 Nov 1997 17:21:24 -0800 (PST)
Message-Id: <199711130121.RAA04374@adit.ap.net>
Mime-Version: 1.0
To: "Ashod" <ashod AT ozemail DOT com DOT au>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: wierd problem

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019