wierd C++ "error?"

Miscellaneous Forums/General Discussion/wierd C++ "error?"

Hi, I'm trying to do some basic C++, and for some reason, on a basic hello world program, the window only flashes for a frame then dissappears. Any ideas?

//Test
#include <iostream>

int main()
{
	std::cout << "HELLO WORLD!!";
	return 0;
	
}


Yes, the console window is closed when the program ends. run it from the console command window.

ehh...what exactly is the console command window?
/noob

Start > Run > type "cmd"

EDIT: For Windows. :)

how can I make it so the program waits for any key to be pressed, then continue?

I think you can use getch(); can't remember if it is in iostream or conio though...long time no C++ programming here ^^

getch() isn't a command according to visual C++ 2008

try this:

//Test
#include <iostream>

int main()
{
                    char Container;
	std::cout << "HELLO WORLD!!";
         std::cin >> Container; //quits after enter
	return 0;
	
}


ok, that works well enough, thanks

An alternative would be to open the command prompt, call "CD" till you get to your .exe's directory, then just call:

Yourexesname.exe

and the window won't vanish

Interesting, turns out getch() is 'non standard' ^^

Another alternative is calling system("PAUSE")