Errors??

Discussion in 'Programming' started by chum112, Mar 8, 2007.

  1. #1
    Thanx guys i fixed it. It was the semi colons after my first two cins and last cout lol
     
    chum112, Mar 8, 2007 IP
  2. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You're missing semi-colons at the end your first two cins and your last cout.

    Surely, though, you would have got error messages? It helps if you tell us what you've been told.
     
    TwistMyArm, Mar 8, 2007 IP
  3. chum112

    chum112 Guest

    Messages:
    1,131
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    When i execute the program it shuts down after it completes the required steps. How can i make it so the programm stays open to show me the results for longer without shutting down as soon as it processes the results?
     
    chum112, Mar 8, 2007 IP
  4. Xangis

    Xangis Active Member

    Messages:
    182
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    78
    #4
    You would use a loop for that sort of thing.

    For instance,

    int main(char* argc, int argv)
    {
    bool done = false;
    <variable initialization here, i.e. float a,b,c,d,e,f>
    while ( done == false )
    {
    <put your input and output code here>
    <add some condition here that would set done = true, such as
    when the user enters 0 for the first number>
    }
    return 0;
    }

    You should be able to get the exact details from any C++ reference, but a while loop combined with a condition variable should do what you want.
     
    Xangis, Mar 8, 2007 IP
  5. chum112

    chum112 Guest

    Messages:
    1,131
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Im at a beginners stage and i realy dunt understand the computer jargon lol. Soz
     
    chum112, Mar 8, 2007 IP
  6. Xangis

    Xangis Active Member

    Messages:
    182
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    78
    #6
    If you have access to a copy of the Teach Yourself C++ In 21 Days book I highly recommend reading it if you're serious about learning to write C++. It makes things a lot easier.
     
    Xangis, Mar 8, 2007 IP
  7. chum112

    chum112 Guest

    Messages:
    1,131
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yeh i have been using my textbooks but its not in there. IS there a code such as cout << "leave window open"<<endl; . etc?
     
    chum112, Mar 8, 2007 IP
  8. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Not really, no. You can, however, cout 'Press any key to close this window' then cin something... that will essentially wait for you to press a key / enter.
     
    TwistMyArm, Mar 9, 2007 IP