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 !
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.
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 -
1 2 3 4 5 6 7 8 9
//let me call this page 1
int n;
do
{
cout<<"1-Menu 1 \n2-Menu 2 \n3-Exit ";
cin>>n;
} while(n!=3);
Now suppose menu 1 takes me to a 'new' page (using clrscr();)
how do i come back to page1 ?
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.
void function1() {
//task here
}
void function2() {
//task here
}
void function3() {
//task here
}
int main() {
int num1, num2, num3;
while (true) {
cout << "Enter a number. -1 to skip all loops" << endl;
cin >> num3;
if (num3 == -1) break;
function1();
while(true) {
cout << "Enter a number. -1 to skip the last loop" << endl;
cin >> num2;
if (num2 == -1) break;
function2();
while(true) {
cout << "Enter a number. -1 to skip this loop" << endl;
cin >> num1;
if (num1 == -1) break;
function1();
} //brace for function1();
} //brace for function2();
} //brace for function3();
return 0;
} //for main