Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    28
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Question why does it close?

    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.

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    You can use system("pause"); to hold the window open as well.
    OracleGuy

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    28
    Thanks
    9
    Thanked 0 Times in 0 Posts
    oracle guys, u are a genius ^.^


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •