Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Can't run C programs properly(Eclipse C programs don't run on WnXP SP3 properly)
Can't run C programs properly [message #1033479] Thu, 04 April 2013 09:14 Go to next message
Bapan Baptwo is currently offline Bapan BaptwoFriend
Messages: 2
Registered: April 2013
Junior Member
Hello all, I use Eclipse for C programs and that runs absolutely fine on Ubuntu. However, it is not same for Windows. I use Eclipse on WinXP SP3. I have downloaded Eclipse Classic and have installed new software for C support. I have MinGW installed & system variable set properly on my Windows machine.

I can run the preloaded "Hello World !" program in Eclipse - it gives correct output. But other programs are not running properly. For example, take this code snippet :
---------------------------
#include<stdio.h>
#include<stdlib.h>

int main()
{
int i;
printf("Hello World !\n");
printf("Hello World !\n");
printf("Enter an integer : ");
scanf("%d", &i);
printf("The entered integer was : %d", i);

return 0;
}

-----------------------------
I can build the project without any error but it doesn't run properly. When I click on run button it displays nothing in the "Console" window. However, after clicking the red-colored square-shared "Terminate" button, I get the following output :
-----------------------------
Hello World !
Hello World !
Enter an integer : The entered integer was : 2147348480



Re: Can't run C programs properly [message #1035263 is a reply to message #1033479] Sat, 06 April 2013 15:56 Go to previous messageGo to next message
Klaus Mr is currently offline Klaus MrFriend
Messages: 121
Registered: November 2011
Senior Member
check:
http://wiki.eclipse.org/CDT/User/FAQ#Eclipse_console_does_not_show_output_on_Windows

regards,
Klaus


Re: Can't run C programs properly [message #1039386 is a reply to message #1035263] Fri, 12 April 2013 05:34 Go to previous message
Bapan Baptwo is currently offline Bapan BaptwoFriend
Messages: 2
Registered: April 2013
Junior Member
I added the following two lines at the beginning of main() function.

setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);


It worked absolutely fine. Thank you very much Klaus.
Previous Topic:Run control not available
Next Topic:stdout not Displayed with Command Line Arguments
Goto Forum:
  


Current Time: Tue Nov 25 21:23:52 GMT 2014

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

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