OUTPUT HELLO

H

Hello

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;

}
 
S

Sarath

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
 
J

Jim Langston

Hello said:
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 said:
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();
 
O

osmium

Hello said:
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();
 
T

tony

Hello said:
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)
 
R

RGambord

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
 
I

Ian Collins

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++.
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

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.
 
D

David Harmon

On Tue, 19 Jun 2007 11:50:38 +1000 in comp.lang.c++, "Hello"
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.
 
M

Marcus Kwok

Jim Langston said:
Hello said:
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 <Enter> to continue...\n";
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
 
A

attibln

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
 
Z

Zachary Turner

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.
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top