Complete n00b Needs Help with cout...

H

HardHackz

Hey, I'm trying to learn C++, the problem is, when I do cout << "Hello
World!"; it always opens dos and closes it to quickly to see...i know
im a total n00b, but any help?
 
V

Victor Bazarov

Hey, I'm trying to learn C++, the problem is, when I do cout << "Hello
World!"; it always opens dos and closes it to quickly to see...i know
im a total n00b, but any help?

Add some input at the end of your program to hold it. I've seen

system("pause");

proposed, but it may not work on your system. Try

std::cout << "press enter";
std::string a;
std::cin >> a;

V
 
S

shadowman615

Hey, I'm trying to learn C++, the problem is, when I do cout << "Hello
World!"; it always opens dos and closes it to quickly to see...i know
im a total n00b, but any help?

Sounds like you might be using Visual C++. You can also compile and
build your program from within Visual C++, then manually open a
command (console) window and run the resultant executable from there.
 
H

HardHackz

Sounds like you might be using Visual C++. You can also compile and
build your program from within Visual C++, then manually open a
command (console) window and run the resultant executable from there.

No, I'm not using Visual C++ but thanks for the help and thanks for
the help Victor.
 
M

Marcus Kwok

Victor Bazarov said:
Add some input at the end of your program to hold it. I've seen

system("pause");

proposed, but it may not work on your system. Try

std::cout << "press enter";
std::string a;
std::cin >> a;

Another option that doesn't require a temporary string, but at the
expense of more typing, is:

std::cout << "press enter";
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
 
V

Victor Bazarov

Default said:
You'll never get me to respond to that, not after that John Varley
story.

Let's hope not many have read it (I didn't for instance). :)

V
 
O

Old Wolf

Add some input at the end of your program to hold it. I've seen

system("pause");

proposed, but it may not work on your system. Try

std::cout << "press enter";
std::string a;
std::cin >> a;

Simpler is:
std::cin.get();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top