I made my first "hello world" program and successfully compiled it, and when I open the .exe it clearly says what it's suppose to, but it just closes as soon as it opens. Here's the script I used:
#include <stdio.h>
int main(void)
{
printf_s("Hello, World!\n");
}
So my question is, is there some kind of code I need to add to it to keep the program from closing, or is there another problem I'm not seeing?
Comments
1) open up cmd and launch the program from within the command
or
2) add getchar(); to the end of your program. This will cause the program to hang until you type a character (press a key), so:
The reason it does this is because it assumes you're in a persistent console.
You could also use:
right?