delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/09/19:26:47

Message-ID: <33234ED6.70F0@pobox.oleane.com>
Date: Mon, 10 Mar 1997 00:59:18 +0100
From: Francois Charton <deef AT pobox DOT oleane DOT com>
Organization: CCMSA
MIME-Version: 1.0
To: LSC <liausc AT pl DOT jaring DOT my>
CC: djgpp AT delorie DOT com
Subject: Re: please help, wrong result from this program
References: <01bc2cbc$6888c980$63708ea1 AT a>

LSC wrote:
> 
> #include <conio.h>
> #include <stdio.h>
> 
> int main()
> {
>   char keyinput;
>   gotoxy(2,2);
>   printf("testing");
>   gotoxy(5,15);
>   printf("testing 2");
>   while (keyinput != 13) keyinput=getch();
>   return 0;
> }
>

In DJGPP, stdio functions are buffered: the strings you write with printf 
(for instance) are written into a buffer, which is output to the screen 
either when the buffer is full, or when a "\n" is seen, or when you call 
fflush(stdout). 

To make your program behave the way you want it to, you may either
- use printf("testing\n"); (note the \n)
- use cprintf instead of printf
- call fflush(stdout) after printf() so that the contents of the printf 
are dumped to the screen. 

Francois

- Raw text -


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