Just wanted to say thanks...and another question...

This is a discussion on Just wanted to say thanks...and another question... within the C++ Programming forums, part of the General Programming Boards category; Thanks to everyone who has helped me in the past. It has helped me to become a better programmer. Now ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    67

    Smile Just wanted to say thanks...and another question...

    Thanks to everyone who has helped me in the past. It has helped me to become a better programmer. Now for my question. I have a calculator type program. So after each number it asks if you wish to quit. If there a way that I can flag a certain location then just warp the user back to that flag? Because I don't know of anyway other than not asking and just making the progam exit after every number..Help?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Try a loop

    Code:
    while(1){
    
    if(certain condition for quit)break;
    else{
    
    //Do stuff
    }
    
    }

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    be a bit more specific. do you mean that you accept a key, say with getch(), then you're program straight away wants to quit?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    and by the way, people are more likely to help you if you are more specific in the subject spec. Experienced forum browsers just see, 'please help' and 'just one little question' and 'eeasy problem', and ignore it. believe me, you're better off stating your subject matter where everyone can see it
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    Registered User
    Join Date
    Aug 2002
    Posts
    67

    Let me reexplain it

    Let me rephrase that. After the person does 1 calculation then program quits. So how can i make it so it just restarts the program?

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    loops, loops, loops!

    Code:
    char continue = 'y';
    while(continue == 'y')
    {
       //do something;
       cout << "to stop this loop enter any key but lower case y" << endl;
       cin >> continue;
    }

  7. #7
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by elad
    Code:
    char continue = 'y';
    Ummm, continue is a keyword in C++ and can therefore not be used as a variable name.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  8. #8
    Registered User
    Join Date
    Aug 2002
    Posts
    67

    Ah..

    Thanks for fixing his error. I was wondering why that wasn't working. So where the continue was I use a varible name? Someone please tell me

  9. #9
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    Ooops, yup, use flag or more or Continue or some other variable name instead. Sorry.

  10. #10
    Registered User
    Join Date
    Aug 2002
    Posts
    67

    Question

    Sorry for all these favors but could someone give me a simple program that asks you if you want to continue then loops the code? Cause I am still confused about this. Yes I am an Idiot..lol
    Thx in Advance

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21