O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Keeping Your Application Open

If your application ran so quickly that you didn't even have time to see it, don't be surprised. The reason for this is that on some operating systems (think Windows here) the console application will open, the C executable will run, and the console will close again—that is, unless you do something to stop it.

So here's a little trick you can use if you are having this problem. Simply open your hello.c script and add the getchar() function to your main() function. This will make the application wait for the Enter or Return key to be pressed before continuing to execute.

To keep your application open using getchar()

1.
Open hello.c (Script 1.2) in your text editor or IDE.
2.
After the printf() line and before return ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required