How I can check if one CCString is equal to another CCString?
there is a function on ccstring, called >compare
you have to give it a const char not a string object so do this:
string1~~>compare);
that function returns a number, which i think is the difference between the first letter that is wrong, eg a-b =~~1 or b-d = 2… I think this is for sorting things alphabetically… someone correct me if not?
basically if you get 0 from it, then the string is the same all the way through. so:
if(string1->compare(string2->getCString()) == 0){ //they are the same }else{ //different }
daniel fountain wrote:
there is a function on ccstring, called >compare
you have to give it a const char not a string object so do this:
>
string1~~>compare);
that function returns a number, which i think is the difference between the first letter that is wrong, eg a-b =~~1 or b-d = 2… I think this is for sorting things alphabetically… someone correct me if not?
>
basically if you get 0 from it, then the string is the same all the way through. so:
>
if(string1->compare(string2->getCString()) == 0){ //they are the same }else{ //different }
Thanks a lot