Jump to content
  • Advertisement
Sign in to follow this  
veghta

some help plessss

This topic is 4140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have tryed to make a break when you input quit in this but it will not work odd i think. how would i have my program exit? so to speak thx for the help . i have working on this shell for a good start to understanding c++ because it was made to make shells an os. by the way the loop work a ok in the program #include <iostream> #include <string> using namespace std; int main() { string input; // for input like the ifs int num; // for the loop same as in i here int i; do//part of loop for (i=0; i<10; i++){ cout<<"(:-<_>"; cin>>input; if (input =="help"){ cout <<"------------------------------\n"; cout <<"-List of Comands -\n"; cout <<"------------------------------\n"; cout <<"-help(List of Comands) -\n"; cout <<"-quit(To Program) -\n"; cout <<"- -\n"; cout <<"- -\n"; cout <<"- -\n"; cout <<"- -\n"; cout <<"------------------------------\n"; } if (input == "quit") { cout<<" good bye\n"; } else { cout << "Bad Comand or Bad File Name or Bad Input\n "; } } while(num !=1); return 0; }

Share this post


Link to post
Share on other sites
Advertisement
Ok, first I will scold you twice, and then I'll answer your question :)

1. "some help plessss" is not a helpful topic. Most people tend to ignore threads named like this. Something better would be "how would i have my program exit?" like you have in your post.

2. For the love of god, please use source or code tags when posting source or code! Otherwise, the format is lost, and things with a lot of nesting become difficult to read. There's an explanation of how to do this in the FAQ.

You can fix both of these problems by editing your post (there's a link in the upper right of your post).

Ok, now that I'm done wagging my finger:

Presuming that you don't have anything else to do before you exit, you can simply return from main prematurely. Since the program isn't ending due to an error, continue to use return(0); otherwise you would return(1) (or some other meaningful nonzero number).

ie:


if (input == "quit")
{

cout<<" good bye\n";
return(0); // The program exits here.
}



Share this post


Link to post
Share on other sites
well thx for wagging your finger at me . i will recall the words that you have told me. and thx for the help erissian

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!