www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/13/03:47:21

From: G DOT DegliEsposti AT ads DOT it
To: "Arthur" <arfa AT clara DOT net>
cc: djgpp AT delorie DOT com
Message-ID: <C1256603.00280E44.00@vega.ads.it>
Date: Wed, 13 May 1998 09:33:34 +0200
Subject: Re: Why doesn't this work?
Mime-Version: 1.0




>Yes, I know that it is not optimised fully, but the routine is there and I
>know it works. Why does it not prompt you for your password until after
you
>have typed it?
[...]
>for (count=0;count<5;count++)
>    {
>         while (kbhit()!=0);
>         letter[count]=getch();
>         printf("*");
>    }

In DJGPP "printf" is line buffered. It doesn't output anything until the
buffer
is full or a '\n' is output.

You can override this using the "fflush(stdout)" function. It forces the
buffer
to be put on screen even if none of the two conditions stands.

>It works if I use cprintf or scanf, so I assume that after printf is used,
>the text is not printed until some interrupt is set off (like a function
>call). I thought it was the simple "print to stdout" routine?
It is! cprintf is designed for console output, so it must write every
character
immediately on the screen.
printf is designed for generic stdout output, so it is buffered for
performance reasons.

This is a classical problem most of DJGPP beginners meet (I did too :-)
and IIRC Eli is going to put it on next FAQ release.

ciao
  Giacomo





- Raw text -


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