![]() |
|
#1
|
|||
|
|||
How do you compare two strings? [was: Easy Question I'm sure]How do you compare two strings??
I.E. CPP / C++ / C Code:
Please help Austin Last edited by JdS : 22-Mar-2004 at 16:16.
Reason: Please enclose c code in [c] & [/c] for syntax highlighting
|
|
#2
|
|||
|
|||
|
Quote:
Here's a complete program that works for me (Borland bcc, Microsoft VC++, GNU g++ compilers). What are you using? CPP / C++ / C Code:
Dave |
|
#3
|
|||
|
|||
|
Quote:
Ok I just copyed exactly that and it printed "a is not equal to b" Did you compile and run yours? I'm using microsoft visual C++ Austin |
|
#4
|
||||
|
||||
|
Dave's example works just fine for me, too. The problem you're having is probably unrelated to the equality of the strings. Check your syntax to make sure everything is right.
__________________
-Aaron |
|
#5
|
|||
|
|||
|
I just ran the same code in my msvc++ 6.0 and it works fine. try initializing the strings using constructors: string a("Hey"); string b("Hey");
Quote:
|
|
#6
|
|||
|
|||
|
Quote:
I compiled the program (named st.cpp) and ran with the following command-line compilers: Borland bcc (C++ version 5.5.1) GNU g++ (GCC 3.3.1 cygwin) Microsoft cl (Visual c++ version 6.0) All said: Quote:
Dave |
|
#7
|
|||
|
|||
|
Quote:
I just did a copy-and-paste from this post to see if anything got lost in file upload/download. Still works as advertised. Dave Last edited by davekw7x : 22-Mar-2004 at 13:35.
|
|
#8
|
||||
|
||||
|
Quote:
__________________
-Aaron |
|
#9
|
|||
|
|||
got it!Ok I got it finally. I don't really know what the problem is, but I went to a different computer and used identical code and it worked. So something was wrong with that computer or something. Thanks for the help guys.
Austin |
|
#10
|
||||
|
||||
|
Quote:
__________________
-Aaron |
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Complete, Fast and easy Template System | Allowee | MySQL / PHP Forum | 3 | 07-Feb-2004 11:31 |
| question of practice | magiccreative | C++ Forum | 1 | 06-Feb-2004 08:17 |
| a C input question.. | tmike | C Programming Language | 2 | 19-Sep-2003 03:39 |
| a C input question | tmike | C Programming Language | 1 | 16-Sep-2003 03:31 |
| AVI Joiner, MPEG Joiner, RM Joiner, all is in Easy Video Joiner | SmartHero | Computer Software Forum - Windows | 2 | 08-Mar-2003 03:51 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The