some help plessss

Started by
2 comments, last by erissian 16 years, 9 months ago
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; }
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.	}
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
well thx for wagging your finger at me . i will recall the words that you have told me. and thx for the help erissian
No problem :)
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)

This topic is closed to new replies.

Advertisement