|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
below are a part of my code for my program
it compiles with no error but it does not work properly i am really not good at handling char array and pointers, and do not understand very well. I need the program let user can input command by keyboard and my program would distinguish commands ===== int main(){ int a; BST_node* b; char command[30]; char temp[30]; Contact c; BST book; do{ cout << "Please input command:"; cin >> command[30]; while (command!="insert" || command!="remove" || command!= "show" || command!="list" || command!="total" || command!="exit"){ cout<<endl; cout << "Invalid command"; cin>>command[30]; } cout<<endl; if (command=="insert"){ cout<<"Please enter the name for the new contact:"; cin>>temp; |
| Sponsored Links |
|
|
|
|||||
|
You need to use the function, strcmp, for comparing your array with another string. Another alternative is to use std::string, but if I got you right, you need to work with char arrays? If that's right, then stick to the comparing function I first told you about.
|
|
|||||
|
Another problem you have is the while condition will ALWAYS return true. Instead of using || to connect your options, use &&.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Usage of array structures to increment letter instances of text | Yuriy M | C and C++ | 2 | 09-13-2007 11:49 AM |
| Visual Studio 2003 convert System::String to char array | karateboy02 | Managed C++ | 0 | 07-27-2007 10:00 AM |
| Python 2D array question | annannienann | Python | 3 | 04-23-2007 05:36 PM |
| C++ Array Problem | dksmarte | C and C++ | 4 | 04-13-2007 12:52 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |