| | |
How to exit without exit?
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2003
Posts: 2
Reputation:
Solved Threads: 0
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!!
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!!
•
•
Join Date: Sep 2003
Posts: 81
Reputation:
Solved Threads: 0
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
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!!
•
•
Join Date: Sep 2003
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
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
I'ver got an idea too, how about compare the input string with "-1".
C++ Syntax (Toggle Plain Text)
while(!strcmp(ID,"-1")) { cin << firstName; while(!strcmp(firstName,"-1")) { cin << lastName; } }
•
•
Join Date: Sep 2003
Posts: 81
Reputation:
Solved Threads: 0
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
Ilya
•
•
•
•
Originally Posted by goodwilllV
Thank you for your reply!
I'ver got an idea too, how about compare the input string with "-1".
How is that? Haven't tried no my code.C++ Syntax (Toggle Plain Text)
while(!strcmp(ID,"-1")) { cin << firstName; while(!strcmp(firstName,"-1")) { cin << lastName; } }
![]() |
Similar Threads
- exit & return in C (C++)
- exit (0) (Shell Scripting)
- ** Need Help ** in a small C++ problem (C++)
- question (C++)
Other Threads in the C++ Forum
- Previous Thread: new to programming
- Next Thread: doesnt make sense
Views: 11616 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





