0

Hey all,

When I write even a hello world script like below

#include <stdio.h>

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

the windows command line flickers when trying to execute it, instead of staying there and showing me ?

Is there anyway to refresh or make this start coming up again.

Thank you

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by Radical Edward
0

That happens when you run the program from an IDE that doesn't keep the window open or if you run the program by double clicking on an icon. It happens because the lifetime of the window is controlled by the lifetime of the program. When execution returns from main, the program ends and the window is destroyed.

The usual solution is to ask for input so that the lifetime of the program is dependent on the user:

#include <stdio.h>

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

Thanks alot,

Yeah I figured it out by just getting a new IDE instead of Dev++.

0

> Yeah I figured it out by just getting a new IDE instead of Dev++.
That's a little drastic. ;) I'm sure some IDE advocates would love you to believe that switching is a walk in the park, but going from one IDE to another has a learning curve that's frustrating proportionally to how long you've been using the old IDE.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.