how can i open the window open

W

wax

Hello.

// i/o example

#include <iostream>
using namespace std;

int main ()
{
int i;
cout << "Please enter an integer value: ";
cin >> i;
cout << "The value you entered is " << i;
cout << " and its double is " << i*2 << ".\n";
return 0;
}

i enter the integer but whan i press enter the programe runs and i can't see
the results.
how can i open the window open?

Thanks
 
J

Jacek Dziedzic

wax said:
Hello.

// i/o example

#include <iostream>
using namespace std;

int main ()
{
int i;
cout << "Please enter an integer value: ";
cin >> i;
cout << "The value you entered is " << i;
cout << " and its double is " << i*2 << ".\n";
return 0;
}

i enter the integer but whan i press enter the programe runs and i can't see
the results.
how can i open the window open?

try adding

int dummy;
cin >> dummy;

before the return. This will wait for a number and an enter.

or add

for(;;) {}

which will result in an infinite loop.

HTH,
- J.
 
W

White Wolf

Jacek Dziedzic wrote:
SNIP]
try adding

int dummy;
cin >> dummy;

before the return. This will wait for a number and an enter.

or add

for(;;) {}

which will result in an infinite loop.

std::cin.get(); ?
 
S

Salt_Peter

wax said:
Hello.

// i/o example

#include <iostream>
using namespace std;

int main ()
{
int i;
cout << "Please enter an integer value: ";
cin >> i;
cout << "The value you entered is " << i;
cout << " and its double is " << i*2 << ".\n";
return 0;
}

i enter the integer but whan i press enter the programe runs and i can't see
the results.
how can i open the window open?

You mean, how can you keep the window open. Typically, by running the
program in the environment it is written for. However, here is a
portable way to pause in the case you are executing a link (instead of
invoking the program from the console):

#include <iostream>
#include <ostream>
#include <limits>

int main(void)
{
// do stuff
std::cout << "Press Enter to Exit.";
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
return 0;
}
 
S

Salt_Peter

VistaUser said:
Give up. You aren't clever enough to use a computer.

Some people don't use English as a first (or even a second language).
Yet he managed to Post a relatively clear question without replicating
*his* Post. Who do you think is more clever?
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top