| | |
Strange function problem!!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 2
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <windows.h> using namespace std; void about(){ cout<<"Expence-List 14/10/2008:"<<endl <<"Brought to you by www.******.com"<<endl <<"Programmed by **********."<<endl; Sleep(4000); system("cls"); } int MenuOne(){ int MenuSelection=0; cout<<"What would you like to do?"<<endl <<"--------------------------------"<<endl <<"1. Create a new expence list."<<endl <<"2. Edit a previous expence list."<<endl <<"3. View a saved expence list."<<endl <<"4. Settings"<<endl <<"5. About."<<endl <<"6. Close Program"<<endl <<"--------------------------------"<<endl <<endl; cin>>MenuSelection; system("cls"); return MenuSelection; } int MenuProcessing(int MenuSize,int MenuSelection){ int b=1; if(MenuSelection>MenuSize){ cerr<<"You've entered an invalid option!"<<endl <<"Try again!."<<endl; Sleep(2000); system("cls"); return 0; } while(MenuSize>b){ if(MenuSelection=b){ } } b++; } int main(){ start: int MenuSelection=0,EventStatis; about(); MenuSelection=MenuOne(); EventStatis=MenuProcessing(6,MenuSelection); if(EventStatis=0){ goto start; } return 0; }
so thats my code right.
where it says the function menuprocessing. I need a menuprocessing thingo cause i using lots and lots of menus.
so what i want is for where the
C++ Syntax (Toggle Plain Text)
while(MenuSize>b){ if(MenuSelection=b){ } }
so something like a function array....
C++ Syntax (Toggle Plain Text)
void MenuOne[1](){ }
so when
C++ Syntax (Toggle Plain Text)
MenuMelection=b
C++ Syntax (Toggle Plain Text)
MenuOne[b]();
sucks that function arrays don't exist.
how would i go about doing something like that?
use a switch statement, then call the function you are after.
I think that is what you are after,
Chris
C++ Syntax (Toggle Plain Text)
switch(b){ case 1: menu1(); break; case 2: menu2(); break; case 3: menu3(); break; default: std::cout << "Invalid Choice!"; break; }
I think that is what you are after,
Chris
Knowledge is power -- But experience is everything
•
•
Join Date: Oct 2007
Posts: 305
Reputation:
Solved Threads: 43
Not to keep harping on this, but you really need to be careful about the difference between an assignment (=) and a comparison (==).
This means that you are assigning the value of the variable b to that of the variable MenuSelection.
[/icode] if(MenuSelection=b){ [/icode]
This means that you are comparing the variables MenuSelection and b
[/icode] if(MenuSelection == b){ [/icode]
This means that you are assigning the value of the variable b to that of the variable MenuSelection.
[/icode] if(MenuSelection=b){ [/icode]
This means that you are comparing the variables MenuSelection and b
[/icode] if(MenuSelection == b){ [/icode]
![]() |
Similar Threads
- Strange cout problem (C++)
- Strange wofstream problem /bug (C++)
- mid problem in access 2003 (Windows NT / 2000 / XP)
- Strange thing... URGENT (ASP.NET)
- WriteFile() function in printf() freezes (C)
- HiJackThis and Panda titanium problem (Viruses, Spyware and other Nasties)
- Problem with Turbo C...or so I think!! (C++)
- Trojan Horse,Download.Trojan not repaired by Norton;network doesn't function (Viruses, Spyware and other Nasties)
- printf buffer strange behaviur (C)
Other Threads in the C++ Forum
- Previous Thread: someone help with simple problem
- Next Thread: use c++ upload video to youtube
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream input int integer java lib linux list loop looping loops map math matrix memory multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






