Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » delayed console display
delayed console display [message #883967] Sat, 09 June 2012 20:16 Go to next message
Tracey is currently offline TraceyFriend
Messages: 14
Registered: July 2009
Junior Member
I ran a tutorial (avg.c - pasted below) that accepts 2 numbers from the
keyboard, but the text from the puts function does NOT appear in the
Eclipse Console Window until after I have entered the 2 numbers.
avg.c runs fine from a DOS window.

The Eclipse Console Window first appears blank.
Then I type the following:
10<enter> the numbers appear in green as I type
20<enter> then the following appears:
Enter the 1st number:
Enter the 2nd number:
The average is 15.000000

Can someone explain to me what I am doing wrong or how I can correct
this issue?
I am using the C Project to build and not the C++ Project.

first.c (see last) was the first program from the tutorial that I
compiled which ran as expected and without issue (first.c does NOT use
keyboard input).

Any help will be appreciated.
Thanks, Tracey
/* avg.c: Averages 2 integers */
#include <stdio.h>
int main() {
int num1, num2;
float sum;
puts("Enter the 1st number:");
puts("Enter the 2nd number:");
sum = num1 + num2;
printf("The average is %f\n", sum/2);
return 0;

/* first.c: A First Program */
#include <stdio.h>
int main() {
puts("Hello World");
return 0;
Re: delayed console display [message #884018 is a reply to message #883967] Sat, 09 June 2012 23:00 Go to previous message
Nick Schweyer is currently offline Nick SchweyerFriend
Messages: 165
Registered: July 2009
Senior Member
yes, the text from puts() should appear before you have to enter a number.
So try a flush(), after puts(). flush() is emptying the output buffer.

I know this procedure when using printf() within a program.
The flush() statement is necessary after a printf(), if the output from printf() shall be visible immediately when the program executes the printf() statement. Otherwise the output occurs only when the output buffer is filled.

Normally puts() contains a flush() statement internally.
If flush() solves your problem then you should have a look on your OS configuration. I am not an expert but anywhere there should be a setting how output buffering occurs.
Perhaps your basic library included by stdio.h is not up to date.

Nick Schweyer

Eclipse Helios, Qt 4.3, Qt integration, open Suse Linux 11.3
Previous Topic:Symbol could not be resolved.
Next Topic:Any way to get CODAN indexer to work with big wxwidgets app?
Goto Forum:

Current Time: Thu Apr 19 23:42:36 GMT 2018

Powered by FUDForum. Page generated in 0.01509 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software