• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Code::Blocks Program Console

balanga

Daemon

Thanks: 49
Messages: 1,738

#1
I'm trying to use Code::Blocks for the first time and trying to run the 'Hello, World!' program.

Is there any way to make the Program Console to stay open until I close it as it seems to pop open momentarily and then disappear.
 

xavi

Active Member

Thanks: 66
Messages: 102

#2
Is there any way to make the Program Console to stay open until I close it as it seems to pop open momentarily and then disappear.
Yes, you need to add a call to the getchar() function after the initial output of 'Hello, World!'. The code should look like this:

Code:
#include <stdio.h>

int main()
{
  printf("Hello World\n");
  getchar();
  return 0;
}
 

balanga

Daemon

Thanks: 49
Messages: 1,738

#3
Thanks for that. It seems like a bit of a kludge, and I would have expected that there would be some option to do this through the User Interface... The number of options is intimidating especially for somone using it for the first time. Maybe I didn't find such an option if there isn't one...