943,697 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 15169
  • C++ RSS
Sep 16th, 2003
0

How to exit without exit?

Expand Post »
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!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
goodwilllV is offline Offline
2 posts
since Sep 2003
Sep 16th, 2003
0

Re: How to exit without exit?

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

Quote 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!!
Reputation Points: 13
Solved Threads: 0
Junior Poster in Training
Valmian is offline Offline
82 posts
since Sep 2003
Sep 16th, 2003
0

Re: Re: How to exit without exit?

Quote 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".
C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
goodwilllV is offline Offline
2 posts
since Sep 2003
Sep 16th, 2003
0

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

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

Quote originally posted by goodwilllV ...
Thank you for your reply!
I'ver got an idea too, how about compare the input string with "-1".
C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 13
Solved Threads: 0
Junior Poster in Training
Valmian is offline Offline
82 posts
since Sep 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: new to programming
Next Thread in C++ Forum Timeline: doesnt make sense





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC