Zombie window / blank cmd / hello world

just wanted to start by saying hello and thanks for any help you guys can give me.

Okay im very new to the C++ world but i cant even start at the moment.

1
2
3
4
5
6
7
#include <iostream>
int main( void )
{
using std::cout;
cout << "Hello World!\n";
return 0;
}


i use this code and start it by using ctrl+f5

i get zero error's but then i get a blank cmd screen and the project name as .exe in my process list and i can't stop it and can't close the cmd window either.

Im running windows 7 64bit and using Microsoft Visual C++ 2008 Express Edition
For one, your using needs to be outside the main, under the #include
Try:
1
2
3
4
5
6
7
8
9
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}
i will try that just adding little info im using this book : C++ Programming for the absolut beginner. this is what they gave me :

Now, gentle reader, let us delve head first into the mystical world of C++. Though you may be
overwhelmed at first with the odd symbols and cryptic terms, it will all become clear in time.
So ready your torch and let us delve into this dark cavern!
1
2
3
4
5
6
7
8
//1.1 – Hello World – Mark Lee
#include <iostream>
int main( void )
{
using std::cout;
cout << "Hello World!\n";
return 0;
}

The above is a complete C++ program. It simply displays the words, “Hello World” to the
screen. Now, let’s take it apart, line-by-line!
okay just used your code same problem no errors but CMD window apears no text nothing and programm just dous nothing. cant stop it using shift+f5 or ctrl-C and also cant stop the process by trying to kill it.

It's a bit hard to explain maybe i should make a film and post it on youtube to show you guys what happens?

http://www.youtube.com/watch?v=9d_USzWFxPE

hope this helps
Last edited on
Just wondering, are you actually making this in a Win32 console application and under a cpp file?

If you are then I'm not sure what the problem is but maybe try a different compiler
Just wondering, are you actually making this in a Win32 console application and under a cpp file? Yes i did. How do you change compiler ?
How do you change compiler ?

What program are you using to write and compile your code?
Last edited on
Microsoft Visual C++ 2008 Express Edition so guesing this is also the compiler :P
I have Microsoft Visual Studio 2011 and it works on that. You can upgrade, or try Code::Blocks
okay this is strange i changed compiler and still getting the same problem check the youtube link to see whats happening.

http://www.youtube.com/watch?v=9d_USzWFxPE
I saw on your video that another instance of the cmd opened and then instantly closed.

Try adding
system("PAUSE");

to the bottom of your main function before the return just to see if your window is opening and instantly closing.
closed account (zb0S216C)
[-1 from TheJJJunk for suggesting the use of "system( )"]

apeachaday wrote:
"For one, your using needs to be outside the main, under the #include"

No, they do not. I fact, it's far better than "using namespace ...".

@mythrix: Try running your program from command-prompt. This is how you should be executing your programs, since console programs should not be held open.

Wazzak
Last edited on
Topic archived. No new replies allowed.