| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
:( Unkown Error!
I have no clue what is wrong, something to do witht the "char" maybe? I an a stUpiD n00b.... I have no clue what is going on... Well, Here is my code, it is just something that I thought of:
#include "iostream.h" void dispmenu(int menu) { if(menu = 1){ //system("cls"); cout << "Calculator" << endl; } if(menu = 2){ char *ftp_pass = ""; cout << "Please Enter Password: "; cin >> ftp_pass; if(ftp_pass = "31337"){ cout << "1. Ping" << endl; cout << "2. Net Send" << endl; } } } int main() { //Define Vars ftp_ is just so I know that I defined the var char *ftp_name = ""; int ftp_menu = 0; //Get Name From User cout << "Please Enter Your Name: "; cin >> ftp_name; //Display Menu cout << "Welcome " << ftp_name << ": X" << endl; cout << "1: Math" << endl; cout << "2: h4x0r" << endl; cout << "3: Other" << endl; //Pause cin.get(); //Get Input From User cout << "Please Select A Menu (1-3): "; cin >> ftp_menu; //GoTo: Switch Statement switch(ftp_menu){ case 1 : dispmenu(1); case 2 : dispmenu(2); case 3 : dispmenu(3); } cin.get(); return 0; } |
|
#2
|
|||
|
|||
|
Major defect I can see in your code is that your if stmt. does not contain a conditinal stmt., it is containing an assignement stmt. Hence both if stmts. outside main() will be satisfied.
Secondly, there are no break stmts. between each case in your main(). |
|
#3
|
|||
|
|||
|
Do you get a Compilation error, a runtime error or your programm simply does not what supposed to? (after you fix what Cirus said, of course)
|
|
#4
|
|||
|
|||
|
What cirus said. Also your code:
char *ftp_name = ""; cin >> ftp_name; is a runtime error waiting to happen. You've declared a pointer to a char, but no space for the character(s). Also, when you try read cin into ftp_name, it's pointed at a constant "" and that can't be changed. Try something like this instead: char ftp_name[40]; // or however many characters you think you will need. cin >> ftp_name; |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > :( Unkown Error! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|