| Us5 (2) | |
|
Hi everyone. This is my first post - so please go a bit easy on me :P - See , i've been learning c++ for a major part of the year (last year) in school - and all students have to make this 'database management' project to accompany our school leaving exams - and i've made one - but the problem is that i got so engrossed in my other subjects - i totally forgot about this project - but i DID make a fairly functionable project earlier - a really library management system - but my teacher found plenty of errors in it - and didn't exactly tell me what to do about them .... So here's my code - could some please help me with this ? i've got my leaving exam in less than a week - so i don't want to sound like an arrogant self centered idiot - please, its really urgent ....... What my teacher says - -goto() should not be used in any case -main() cannot be called from another function How can i create 'recurring' menus otherwise ? Also - i've seen that goto() is creating all the run time errors here - If anyone can help - please post an example to go along with the text - thank you so much ! | |
|
Last edited on
|
|
| L B (3806) | |||
| |||
|
|
|||
| maeriden (339) | |
|
Honestly 350 lines of unindented code are too much to read (props for using code tags though). Edited out the rest of the answer to see the OP answer to LB. | |
|
Last edited on
|
|
| greenleaf800073 (82) | |
| Please indent. Really. I don't want to manually indent 350 lines of code in my head. | |
|
|
|
| greenleaf800073 (82) | |
| Indenting makes it easier to read. | |
|
|
|
| Us5 (2) | |||
|
Thanks for the suggestions - L B,maeriden & greenleaf800073 I'll remove the code - there's actually no need for that. I don't know what i was doing last night - 350 lines of un-indented code - really thats just plain stupid - I'll be as precise as possible - @L B - loops.I framed my question incorrectly - you know what the problem is - once i go into a menu - say in this example -
Now suppose menu 1 takes me to a 'new' page (using clrscr();) how do i come back to page1 ? That's what i want to know. | |||
|
Last edited on
|
|||
| AbstractionAnon (517) | |
|
Let your menus be functions. When you want to to exit a menu, you exit the function. You want to display a sub-menu, call a function to handle the submenu. When you exit the submenu, you return to the calling menu. When you exit the main menu, return to main and let main exit. | |
|
|
|
| greenleaf800073 (82) | |
|
What the guy above said. | |
|
|
|
| Mark Anthony Laureta (5) | |||
how about this
| |||
|
|
|||
| TheIdeasMan (1753) | |||
|
@Mark Anthony Laureta Instead of all those nested infinite loops & repeated tests, it would be much better to have a switch statement. It is however a good idea to have functions - each case in the switch should call a function. The switch could be enclosed in a while loops like this:
HTH | |||
|
|
|||
| greenleaf800073 (82) | |
|
cout << "Enter 1 for function 1, etc..."; cin >> input; switch(input) { case 1: function1(); break; case 2: and so on. | |
|
|
|