C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 10th, 2005, 06:53 PM
cpress cpress is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 cpress User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 18 sec
Reputation Power: 0
:( 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;
}

Reply With Quote
  #2  
Old March 11th, 2005, 11:43 AM
Cirus Cirus is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 275 Cirus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 45 m 43 sec
Reputation Power: 4
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().

Reply With Quote
  #3  
Old March 11th, 2005, 12:33 PM
Anibal Anibal is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 176 Anibal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 4 h 20 m 48 sec
Reputation Power: 4
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)

Reply With Quote
  #4  
Old March 19th, 2005, 11:54 PM
BoolBooB BoolBooB is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 36 BoolBooB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 35 m 42 sec
Reputation Power: 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;

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > :( Unkown Error!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway