c++ - Another simple' printf ' problem
- john russell (15/15) Sep 08 2002 I'm slowly getting into C using DM IDDE, but I'm having a problem with t...
- Larry Brasfield (8/29) Sep 08 2002 Look up the flush() or fflush() library calls.
- john russell (19/48) Sep 10 2002 Thanks. Have solved problem using _flushall as shown below
- Walter (6/21) Sep 08 2002 last
I'm slowly getting into C using DM IDDE, but I'm having a problem with the following program. I'm using the IDDE on a XP machine. #include <stdio.h> int main(void) { int x; printf("Input value is: "); scanf("%d",&x); printf("\nvalue is %d ",x); getchar(); return 0; } Why does the output window disappear after I input the number 'x'. The last printf command is not written to the screen. This only happens after a scanf comand.
Sep 08 2002
In article <algifn$31bk$1 digitaldaemon.com>, john russell (joru ukonline.co.uk) says...I'm slowly getting into C using DM IDDE, but I'm having a problem with the following program. I'm using the IDDE on a XP machine. #include <stdio.h> int main(void) { int x; printf("Input value is: "); scanf("%d",&x); printf("\nvalue is %d ",x); getchar(); return 0; } Why does the output window disappear after I input the number 'x'. The last printf command is not written to the screen. This only happens after a scanf comand.Look up the flush() or fflush() library calls. Also, since scanf leaves the non-number input on the stream, your getchar() call may not do what you expect with respect to waiting. --Larry Brasfield (address munged, s/sn/h/ to reply)
Sep 08 2002
Thanks. Have solved problem using _flushall as shown below #include <stdio.h> int main(void) { int x,empty; x=100; printf("Input value is: "); scanf("%d",&x); printf("\nvalue is %d ",x); empty=_flushall(); getchar(); return 0; } Thanks again for your help. "Larry Brasfield" <larry_brasfield snotmail.com> wrote in message news:MPG.17e583936b6b94ba989692 news.digitalmars.com...In article <algifn$31bk$1 digitaldaemon.com>, john russell (joru ukonline.co.uk) says...theI'm slowly getting into C using DM IDDE, but I'm having a problem withlastfollowing program. I'm using the IDDE on a XP machine. #include <stdio.h> int main(void) { int x; printf("Input value is: "); scanf("%d",&x); printf("\nvalue is %d ",x); getchar(); return 0; } Why does the output window disappear after I input the number 'x'. Thescanfprintf command is not written to the screen. This only happens after acomand.Look up the flush() or fflush() library calls. Also, since scanf leaves the non-number input on the stream, your getchar() call may not do what you expect with respect to waiting. --Larry Brasfield (address munged, s/sn/h/ to reply)
Sep 10 2002
"john russell" <joru ukonline.co.uk> wrote in message news:algifn$31bk$1 digitaldaemon.com...I'm slowly getting into C using DM IDDE, but I'm having a problem with the following program. I'm using the IDDE on a XP machine. #include <stdio.h> int main(void) { int x; printf("Input value is: "); scanf("%d",&x); printf("\nvalue is %d ",x); getchar(); return 0; } Why does the output window disappear after I input the number 'x'. Thelastprintf command is not written to the screen. This only happens after ascanfcomand.You need to open a console window (also called a command prompt), and run the program from within that.
Sep 08 2002