By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 2,928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

OUTPUT HELLO

P: n/a
Hi every one.

The famous Hello code below written by C++. through its mother program
"Visual studio 2005"

When I make copy to all files of this program and click on .EXE file away
from the mother program, the output disappears immediately.

Can any person add a line (may related to" Keypress", so that the output can
stay without disappearing?

Thank to all.

-----------------------------------------------------

#include<iostream>

using std::cout;

using std::endl;

int main()

{

cout<< " HELLO WORLD ";

cout<<endl;

return 0;

}
Jun 19 '07 #1
Share this Question
Share on Google+
11 Replies


P: n/a
On Jun 19, 10:50 am, "Hello" <f...@alphalink.com.auwrote:
Hi every one.

The famous Hello code below written by C++. through its mother program
"Visual studio 2005"

When I make copy to all files of this program and click on .EXE file away
from the mother program, the output disappears immediately.

Can any person add a line (may related to" Keypress", so that the output can
stay without disappearing?

Thank to all.

-----------------------------------------------------

#include<iostream>

using std::cout;

using std::endl;

int main()

{

cout<< " HELLO WORLD ";

cout<<endl;

return 0;

}
Seems this is not really a C++ languge question.
When you double click from explorer, you are creating a console mode
application which end when your program returns. While you executing
program from Visual C++ IDE, the application spawned by vcspawn.exe
which will wait for a user input to exit. i dont know why they
required it while execute program directly from Visual Studio.
You have to call

Jun 19 '07 #2

P: n/a
"Hello" <fa***@alphalink.com.auwrote in message
news:46********@news.chariot.net.au...
Hi every one.

The famous Hello code below written by C++. through its mother program
"Visual studio 2005"

When I make copy to all files of this program and click on .EXE file away
from the mother program, the output disappears immediately.

Can any person add a line (may related to" Keypress", so that the output
can
stay without disappearing?

Thank to all.

-----------------------------------------------------

#include<iostream>
#include <string>
using std::cout;

using std::endl;

int main()

{

cout<< " HELLO WORLD ";

cout<<endl;
std::string wait;
std::getline( std::cin, wiat );
return 0;

}
There is another easier way that doesn't require you to create a
std::string, but I can't remember it. cin.somethingorother();
Jun 19 '07 #3

P: n/a
"Hello" writes:
The famous Hello code below written by C++. through its mother program
"Visual studio 2005"

When I make copy to all files of this program and click on .EXE file away
from the mother program, the output disappears immediately.

Can any person add a line (may related to" Keypress", so that the output
can
stay without disappearing?

Thank to all.

-----------------------------------------------------

#include<iostream>

using std::cout;

using std::endl;

int main()

{

cout<< " HELLO WORLD ";

cout<<endl;
add this line:

cin.get();
return 0;

}


Jun 19 '07 #4

P: n/a
Hello wrote:
Hi every one.

The famous Hello code below written by C++. through its mother program
"Visual studio 2005"

When I make copy to all files of this program and click on .EXE file away
from the mother program, the output disappears immediately.

Can any person add a line (may related to" Keypress", so that the output can
stay without disappearing?

Thank to all.

-----------------------------------------------------

#include<iostream>

using std::cout;

using std::endl;

int main()

{

cout<< " HELLO WORLD ";

cout<<endl;

return 0;

}

start->run->(type 'cmd')->
(go to the directory where your .exe is)->(execute it)
Jun 19 '07 #5

P: n/a
Bah. Visual Studio 2005 is not a mother program. I recommend not using
it because Microsoft screwed up the c++ language. I used to be happy
programming with Turbo c++ 3.0. Those were the days. Microsoft decided
to come along and make their _interpretation_ of c++. Bah I say. Give
me CONIO.H. That's right. Microsoft doesn't work with conio. Why?
'Cause they don't. That simple. They just chose not to implement it.

/end rant

Jun 19 '07 #6

P: n/a
RG******@gmail.com wrote:
Bah. Visual Studio 2005 is not a mother program. I recommend not using
it because Microsoft screwed up the c++ language. I used to be happy
programming with Turbo c++ 3.0. Those were the days. Microsoft decided
to come along and make their _interpretation_ of c++. Bah I say. Give
me CONIO.H. That's right. Microsoft doesn't work with conio. Why?
'Cause they don't. That simple. They just chose not to implement it.
Which is fine and dandy because conio.h isn't part of standard C++.

--
Ian Collins.
Jun 19 '07 #7

P: n/a
On 2007-06-19 03:50, Hello wrote:
Hi every one.

The famous Hello code below written by C++. through its mother program
"Visual studio 2005"

When I make copy to all files of this program and click on .EXE file away
from the mother program, the output disappears immediately.

Can any person add a line (may related to" Keypress", so that the output can
stay without disappearing?

Thank to all.

-----------------------------------------------------

#include<iostream>

using std::cout;

using std::endl;

int main()

{

cout<< " HELLO WORLD ";

cout<<endl;

return 0;

}
There are two ways to do this, the first is to modify the program
(adding the std::cin.get() call). However I'm not very fond of this
method since it changes to program and gives it a behaviour that you
might not want when you start using it in real life. What you can do,
which does not require any changes to the code, is to run it from the
Visual Studio environment by pressing Ctrl+F5.

--
Erik Wikström
Jun 19 '07 #8

P: n/a
On Tue, 19 Jun 2007 11:50:38 +1000 in comp.lang.c++, "Hello"
<fa***@alphalink.com.auwrote,
>When I make copy to all files of this program and click on .EXE file away
from the mother program, the output disappears immediately.
Do not "click on" anything. Type the name of the program as a command
to the command line shell.
Jun 19 '07 #9

P: n/a
Jim Langston <ta*******@rocketmail.comwrote:
"Hello" <fa***@alphalink.com.auwrote in message
news:46********@news.chariot.net.au...
>Hi every one.
When I make copy to all files of this program and click on .EXE file away
from the mother program, the output disappears immediately.

Can any person add a line (may related to" Keypress", so that the output
can
stay without disappearing?

#include <string>
[snip]
>
std::string wait;
std::getline( std::cin, wiat );

There is another easier way that doesn't require you to create a
std::string, but I can't remember it. cin.somethingorother();
It's a little more verbose, but it's cin.ignore(). Usage is shown
below.
#include <iostream>
#include <limits>

int main()
{
using std::cin;
using std::cout;
using std::numeric_limits;
using std::streamsize;

cout << "Press <Enterto continue...\n";
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jun 19 '07 #10

P: n/a
On Jun 19, 3:50 am, "Hello" <f...@alphalink.com.auwrote:
cout<<endl;

return 0;
Easyest was to do so is to put
System( "pause" );
betrween the two commands above.
Note that this is M$ specific, so I strongly suggest to use the
solutions in the other replies!

peace

Jun 20 '07 #11

P: n/a
On Jun 18, 11:13 pm, RGamb...@gmail.com wrote:
Bah. Visual Studio 2005 is not a mother program. I recommend not using
it because Microsoft screwed up the c++ language. I used to be happy
programming with Turbo c++ 3.0. Those were the days. Microsoft decided
to come along and make their _interpretation_ of c++. Bah I say. Give
me CONIO.H. That's right. Microsoft doesn't work with conio. Why?
'Cause they don't. That simple. They just chose not to implement it.

/end rant
Have you even used Visual Studio 2005, or are you just rehashing your
thoughts over Visual C++ 5.0? What parts of their interpretation of
the C++ Standard did they fail so hard in that you prefer Turbo C++
3.0 over it?
To the OP,

cin.get();

is the simplest, least verbose way to achieve the desired affect.

Jun 20 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.