Mail Archives: djgpp/1997/01/28/01:49:12
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 -