Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » No desired console otput(Undesired output)
icon9.gif  No desired console otput [message #1752033] Wed, 18 January 2017 06:06 Go to next message
Akshay Pimpalkar is currently offline Akshay PimpalkarFriend
Messages: 2
Registered: January 2017
Junior Member
I have Eclipse for C/C++ IDE as well as Eclipse for Java IDE with C/C++ development tools. When I run the simple C program such as below:

#include<stdio.h>

	int num;
	int i;
	int temp = 1;


int main(){


	printf("Enter number: ");
	scanf("%d", &num);


	if(num == 1){
		printf("1 is not a prime number!");
	}else{
		for(i = 2; i<=num; i++){
			if((num % i == 0) && (i != num)){
				printf("%d is not a prime number!", num);
				temp = 0;
				break;
			}else{
				continue;
			}
		}
		if(temp == 1){
			printf("%d is a prime number!", num);
		}

	}

	return 0;
}


On clicking 'run' button, the console outputs nothing (blank), however it should show the String-"Enter number: " and wait for the input. But the fact is when i enter the value as an input to the program, then it shows that string (i.e."Enter the name: ") and along with the actual output of the program. Form exact information, check out the image as an attachment with this post.
Re: No desired console otput [message #1752103 is a reply to message #1752033] Wed, 18 January 2017 19:44 Go to previous messageGo to next message
David VavraFriend
Messages: 1415
Registered: October 2012
Senior Member
The console output is buffered depending on the operating system.
You could add fflush(stdout) after every prompt or change the buffering to by line or none.
http://stackoverflow.com/questions/7876660/how-to-turn-off-buffering-of-stdout-in-c

icon7.gif  Re: No desired console otput [message #1752127 is a reply to message #1752103] Thu, 19 January 2017 06:09 Go to previous message
Akshay Pimpalkar is currently offline Akshay PimpalkarFriend
Messages: 2
Registered: January 2017
Junior Member
Hey Thanks David for the prompt reply Smile . I will definitely try this solution and I believe it will solve the problem. Sorry for the typing mistakes in the post Very Happy .
Previous Topic:Custom CDT build parser for auto discovery
Next Topic:Newbi Question regarding complete C enviorment
Goto Forum:
  


Current Time: Wed Jan 26 00:12:07 GMT 2022

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

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

Back to the top