String comapre problem


I have a code like this why the© alwasys one?
I use D4 is still say© is true

        String::String notename = MidiMessage::getMidiNoteName( midiNoteNumber, 0, 0, 0);
        if ({
        }else flag=0;
        int temp;
        if ({
        }else flag=0;
        if (flag==1){

pls ,help thank you


From the manual:

Case-sensitive comparison with another string.

0 if the two strings are identical; negative if this string comes before the other one alphabetically, or positive if it comes after it.

i.e. identical == 0 -> casted to bool means false
not identical != 0 -> casted to bool means true

If you use compare just for equality, you should write:

if ( != 0){


…also, I am assuming that C is a string defined as String C (“C”); right? otherwise write compare (“C”), does the same


It still not working© is true

    String::String C={"C"};
    String::String G={"G"};


My bad, I meant

if ( == 0){

is the case, if they are equal, sorry :wink:


Thank you, the problem solved


You might want to invest a bit of time learning basic C++ syntax - I’m amazed that the compiler would accept something like that.