Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » problem in printing in console
problem in printing in console [message #716901] Thu, 18 August 2011 14:10 Go to next message
Eclipse UserFriend
#include <stdio.h>
#include <stdlib.h>

int main(void) {

char* string;


string=malloc(80);
puts("enter the string");

gets(string);

puts(string);
return EXIT_SUCCESS;
}

this is a c program. I am using CDT as development environment and using MINGW for compilation. when i run this program ,it asks for input before printing "enter the string" then after entered input it is printing "enter the string" when i run the .exe file in debug folder it is working properly. Is there any mistake in eclipse CDT.
Re: problem in printing in console [message #717048 is a reply to message #716901] Fri, 19 August 2011 03:09 Go to previous messageGo to next message
Eclipse UserFriend
This is a bug (feature?) of the Windows console in Eclipse.
Here is a detailed explanation and a workaround
http://wiki.eclipse.org/CDT/User/FAQ#Eclipse_console_does_not_show_output_on_Windows
Re: problem in printing in console [message #717143 is a reply to message #717048] Fri, 19 August 2011 08:18 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for your answer. Now it is working properly,can you tell why it behaves like that. I am unable to get, how a single statement making the program to work correctly.

setvbuf(stdout, NULL, _IONBF, 0);


can you explain it??
Re: problem in printing in console [message #717713 is a reply to message #717143] Mon, 22 August 2011 03:16 Go to previous messageGo to next message
Eclipse UserFriend
On 8/19/2011 2:18 PM, hariharan wrote:
> I am unable to get, how a single statement making the program to work
> correctly.
>
> setvbuf(stdout, NULL, _IONBF, 0);
>
>
> can you explain it??

Axel gave you the link to the explanation. Read it. (The setvbuf
statement is actually "obvious" to anyone who ever used file I/O.)

Please also read
http://catb.org/~esr/faqs/smart-questions.html
Re: problem in printing in console [message #718138 is a reply to message #717713] Tue, 23 August 2011 07:36 Go to previous message
Eclipse UserFriend
You can also try adding this line to your gdbinit file:

set new-console on

This only works for Windows and will pop up a new window to show the output.

Marc
Previous Topic:[SOLVED]: Customizing default Workspace Preferences
Next Topic:gcc error when building makefile build via eclipse -not via console
Goto Forum:
  


Current Time: Sun Jul 13 04:19:05 EDT 2025

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

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

Back to the top