Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Output does not show in the Console
Output does not show in the Console [message #1804425] Mon, 25 March 2019 23:50 Go to next message
Abdel  Nabil Soliman is currently offline Abdel Nabil SolimanFriend
Messages: 2
Registered: March 2019
Junior Member
I wrote a small program in Eclipse Cpp 2019 3 and when I run the program, nothing shows in the console. My program is this:
#include <stdio.h>

int main(void)
{
 int integer1;
 int integer2;
 int sum;
 printf("enter first integer\n");
 scanf("%d", &integer1);

 printf("enter second integer\n");
 scanf("%d", &integer2);

 sum = integer1 + integer2;

 printf("Sum is %d\n",  sum);
}
 

As you can see there is nothing wrong with the code, but when I build and run it the output should show up in the console with the first string being "enter first integer", though nothing shows in the console. So I tried to enter the integer1 and integer2 in the console and pressed enter. The output and the result for the given integer1 and integer2 than show in the console. My question is How do I fix it or is there a certain setting I need to do? Thank you.
Re: Output does not show in the Console [message #1804427 is a reply to message #1804425] Tue, 26 March 2019 00:40 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Depending on the OS, the output is buffered.
Try doing fflush(stdout); after each prompt.

You can also set the buffering to NO BUFFERING (_IONBF) or
LINE BUFFERING (_IOLBF) using setvbuf.
http://www.cplusplus.com/reference/cstdio/setvbuf/


Previous Topic:CMake, Eclipse, and source directory issues
Next Topic:I want to download SonarQube Eclipse plugin
Goto Forum:
  


Current Time: Thu Apr 25 08:50:17 GMT 2024

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

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

Back to the top