How to exit without exit?

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2003
Posts: 2
Reputation: goodwilllV is an unknown quantity at this point 
Solved Threads: 0
goodwilllV goodwilllV is offline Offline
Newbie Poster

How to exit without exit?

 
0
  #1
Sep 16th, 2003
Home work agian.

I'm required to write a sales analysis program.

One of the function dose enter a new salesperson, it will prompt for personal detail. but if user keys in -1 at any point, it will cancel process and return to main menu options.

BUT according the programming standards of this, " GOTO statement, BREAK keyword and EXIT function are NOT allowed in any program. In C++ the use of Return to jump out of a function premeaturely is not Structured and therefore not allowed".

What can I do ?Thanks!!
Reply With Quote Quick reply to this message  
Join Date: Sep 2003
Posts: 81
Reputation: Valmian is an unknown quantity at this point 
Solved Threads: 0
Valmian Valmian is offline Offline
Junior Poster in Training

Re: How to exit without exit?

 
0
  #2
Sep 16th, 2003
Ok.. here is a very stupid idea..
Multithread, one thread that is suspendd for the main menue. One for input and one for checking for '-1'. If the third thread finds '-1' make it suspend the input and checking (itself) threads and activate the main meue thread. Although I am sure that a more elegant and easier solution is out there somewhere...
Instead of exit you can use abort().. for breaks use catch(?). And for goto use switch(?) although that would be hard.... I don't see how you need those though...
Ilya

Originally Posted by goodwilllV
Home work agian.

I'm required to write a sales analysis program.

One of the function dose enter a new salesperson, it will prompt for personal detail. but if user keys in -1 at any point, it will cancel process and return to main menu options.

BUT according the programming standards of this, " GOTO statement, BREAK keyword and EXIT function are NOT allowed in any program. In C++ the use of Return to jump out of a function premeaturely is not Structured and therefore not allowed".

What can I do ?Thanks!!
Reply With Quote Quick reply to this message  
Join Date: Sep 2003
Posts: 2
Reputation: goodwilllV is an unknown quantity at this point 
Solved Threads: 0
goodwilllV goodwilllV is offline Offline
Newbie Poster

Re: Re: How to exit without exit?

 
0
  #3
Sep 16th, 2003
Originally Posted by Valmian
Ok.. here is a very stupid idea..
Multithread, one thread that is suspendd for the main menue. One for input and one for checking for '-1'. If the third thread finds '-1' make it suspend the input and checking (itself) threads and activate the main meue thread. Although I am sure that a more elegant and easier solution is out there somewhere...
Instead of exit you can use abort().. for breaks use catch(?). And for goto use switch(?) although that would be hard.... I don't see how you need those though...
Ilya
Thank you for your reply!
I'ver got an idea too, how about compare the input string with "-1".
  1. while(!strcmp(ID,"-1"))
  2. {
  3. cin << firstName;
  4. while(!strcmp(firstName,"-1"))
  5. {
  6. cin << lastName;
  7. }
  8. }
How is that? Haven't tried no my code.
Reply With Quote Quick reply to this message  
Join Date: Sep 2003
Posts: 81
Reputation: Valmian is an unknown quantity at this point 
Solved Threads: 0
Valmian Valmian is offline Offline
Junior Poster in Training

Re: Re: Re: How to exit without exit?

 
0
  #4
Sep 16th, 2003
oh.. ok.. you have to make the entire string -1.. well then your idea is ok.. I though you were dealing with multiparagraph multiple strings that were constantly changed.... ya.. for this purpace your idea is the best..
Ilya

Originally Posted by goodwilllV
Thank you for your reply!
I'ver got an idea too, how about compare the input string with "-1".
  1. while(!strcmp(ID,"-1"))
  2. {
  3. cin << firstName;
  4. while(!strcmp(firstName,"-1"))
  5. {
  6. cin << lastName;
  7. }
  8. }
How is that? Haven't tried no my code.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 11616 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC