Computer Science Canada Comparing char arrays |
Author: | Martin [ Sun Jun 15, 2003 5:00 pm ] | ||
Post subject: | Comparing char arrays | ||
This is my code:
Why is the output 0? |
Author: | octopi [ Sun Jun 15, 2003 5:47 pm ] | ||
Post subject: | |||
When you compare strings the way you have shown, I belive it compares their pointers, and not the acctual data, that is why you get the undesired result. You should use strcmp();
You could of course use std::string to do what you want. (As shown above.) |
: |