...

View Full Version : why does it close?



saadhamza
06-27-2009, 08:33 PM
ok, so here is the very basic code i wrote:

#include <iostream>

int main()
{
using namespace std;

int carrots;

cout << " how many carrots do u have? " << endl;
cin >> carrots;
cout << "here are a few more. keep 'em. " ;
carrots = carrots + 5;
cout << " now u have" << carrots << " carrots. " << endl;
cin.get();
return 0;
}



ok, so where it says cin.get(); in blue, i use that to keep the program open after i click enter so i can read what it says. but it still wont stay open long enough. any ideas why? and im useing a windows vista if that helps with microsoft visual studios express.

oracleguy
06-27-2009, 08:39 PM
You can use system("pause"); to hold the window open as well.

saadhamza
06-27-2009, 08:50 PM
oracle guys, u are a genius ^.^



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum