| daytrader (2) | |||
|
Simple example: A windows form with a textbox for password, button for event, and label for go or no go
Well I thought == is the correct comparison operator to use. But when running the form it always returns "Try again" even if its correct. I'm using VC++ .Net 2003. What's wrong? | |||
|
|
|||
| karakale (14) | |||
maybe this code helps you
http://www.cplusplus.com/reference/cstring/strcmp/ i am not sure this is answer of your question but == operator for strings is not useful. | |||
|
|
|||
| daytrader (2) | |
|
Is strcmp the only option? I've seen other postings saying == is suitable but I couldn't get it to work in my case. What is the easiest way to convert textBox1 text string to array of char? I need to do this because the strcmp arguments only accept char. | |
|
|
|
| karakale (14) | |||
| |||
|
|
|||
| jim80y (181) | |
|
txtPassword and setPassword are pointers to System::String objects. You have to dereference them to compare what they're pointing to: if (*txtPassword == *setPassword)Your code is comparing the two pointers, which are always going to be different. Cheers, Jim | |
|
|
|