469,913 Members | 2,683 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

Complete n00b Needs Help with cout...

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?

Feb 28 '07 #1
8 1226
Ha*******@gmail.com wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Feb 28 '07 #2
On Feb 28, 11:15 am, HardHa...@gmail.com wrote:
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.

Feb 28 '07 #3
On Feb 28, 11:51 am, shadowman...@comcast.net wrote:
On Feb 28, 11:15 am, HardHa...@gmail.com wrote:
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.
No, I'm not using Visual C++ but thanks for the help and thanks for
the help Victor.

Feb 28 '07 #4
Victor Bazarov <v.********@comacast.netwrote:
Ha*******@gmail.com wrote:
>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;
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::streamsiz e>::max(), '\n');

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Feb 28 '07 #5
Victor Bazarov wrote:
Try

std::cout << "press enter";
You'll never get me to respond to that, not after that John Varley
story.


Brian
Feb 28 '07 #6
Default User wrote:
Victor Bazarov wrote:
>Try

std::cout << "press enter";

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
Feb 28 '07 #7
Victor Bazarov wrote:
Default User wrote:
Victor Bazarov wrote:
Try
>
std::cout << "press enter";
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). :)

Ah. It's a classic SF/mystery/networked AI amok story.


Brian
Feb 28 '07 #8
On Mar 1, 5:19 am, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
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();
Feb 28 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Keith H Duggar | last post: by
8 posts views Thread by Foxy Kav | last post: by
1 post views Thread by Patrick Parks | last post: by
12 posts views Thread by Christo | last post: by
2 posts views Thread by Perrin | last post: by
7 posts views Thread by Alan | last post: by
14 posts views Thread by TuperYabba | last post: by
6 posts views Thread by Charles | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.