![]() |
|
#1
|
|||
|
|||
comparing stringsThis one seems to be very easy but I'm struggling with this for a few hours now.
I need to comapre 2 strings: one is in a pointer and the other is constant. When I write strcmp(*str,"hello"); I get teh following warning : different types for formal and actual parameter 1 This reulting in a runtime error. Any ideas? Ron |
|
#2
|
||||
|
||||
|
Quote:
You are passing a char instead of a char* when you write *str. Try using just strcmp(str,"hello"). __________________
The best damn Sports Blog period. |
|
#3
|
|||
|
|||
I think I'm going blind :)How could I not see that???!!!
Thanks |
|
#4
|
|||
|
|||
one more thing...Can I use a switch statement to compare strings e.g.
CPP / C++ / C Code:
Last edited by dsmith : 19-Oct-2004 at 08:20.
Reason: Please use [c] & [/c] for syntax highlighting
|
|
#5
|
||||
|
||||
|
Unfortunately no. You either need to string together a bunch of if-else statements or if you are looking for a command parser, you could compare one charecter at a time:
CPP / C++ / C Code:
__________________
The best damn Sports Blog period. |
|
#6
|
||||
|
||||
|
Quote:
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#7
|
||||
|
||||
|
Quote:
What? You don't like it? It has its charms... Your commands could be entered up to only the first unique charecters or the whole command... Not perfect, but certainly not deserving of your EWWWWW! ![]() __________________
The best damn Sports Blog period. |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sprintf Multiple Strings | paulicus | C++ Forum | 4 | 02-Aug-2004 14:14 |
| Including Maps and strings?? | maddie | C++ Forum | 17 | 05-Jul-2004 07:25 |
| Comparing two arrays | Nelly | C++ Forum | 2 | 16-Jun-2004 05:38 |
| help on comparing structs | nusstu | C Programming Language | 4 | 03-Apr-2004 03:22 |
| How do you compare two strings? | soccer022483 | C++ Forum | 9 | 22-Mar-2004 15:45 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The