delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/28/01:49:12

Date: Tue, 28 Jan 1997 01:43:08 -0500 (EST)
From: Michael Phelps <morphine AT hops DOT cs DOT jhu DOT edu>
To: xlysak <xlysak AT fi DOT muni DOT cz>
cc: djgpp AT delorie DOT com
Subject: Re: Ghosts in DJGPP :-)
In-Reply-To: <32ED747F.70BD@fi.muni.cz>
Message-ID: <Pine.GSO.3.95.970128014035.27048B-100000@hops.cs.jhu.edu>
MIME-Version: 1.0

On Tue, 28 Jan 1997, xlysak wrote:

> Can someone help me ? 
> 
> In my program are two function - first is printf() and second is
> getch(), 
> but - first is called getch() and then printf(). Ghosts in the GCC :-)? 
> All examples showed bellow running correctly in Borland C++ 3.1.
> 
> Thanks for all answers !
>                                Marian (xlysak AT informatics DOT muni DOT cz)
> 
> example --->
> 
> void main()
> {
>    int ch;
> 
>    printf("Hi , ");
>    ch = getch();
> }
> 
> Output is (!) :
>   (1) - wait for getch()
>   (2) - Hi ,
> 

Output in DJGPP is buffered by default.  There are a couple quick fixes
for your code:
(1)  printf("Hi , "); -> printf("Hi, , \n"); /* newline forces write */
(2)  fflush(stdout); /* after printf() */

There are additional methods, detailed in the FAQ and my chapter of the
DJGPP Book Project (http://www2.ari.net/flyboy/filedisk.txt).


> void main()
> {
>    int ch;
> 
>    printf("Hi , ");
>    ch = getch();
>    cprintf(" everybody.");
> }
> 
> Output is (!) :
>   (1) - wait for getch()
>   (2) - everybody.Hi ,
> 
> void main()
> {
>    int ch;
> 
>    printf("Hi , ");
>    ch = getch();
>    printf(" everybody.");
> }
> 
> Output is (!) :
>    (1) - wait for getch()
>    (2) - Hi , everybody.
> 
> void main()
> {
>    int ch;
> 
>    cprintf("Hi , ");
>    ch = getch();
>    cprintf(" everybody.");
> }
> 
> Output is (OK) :
>  (1) - Hi ,
>  (2) - wait for getch()
>  (3) - everybody.
> 



						---Michael Phelps
						   morphine AT cs DOT jhu DOT edu


                               CH3
                               |
                               N
                             / |
                     ______/   |
                    /      \   CH2
             _____/         \__|__      
           //     \\        /  |  \\     
         //        \\______/___CH2 \\  
          \        /       \       /
           \______/         \_____/
          / ------ \       /      \
        OH           \   /         OH
                       O
 
                   Morphine



- Raw text -


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