Simple string issue

I have the following 5 lines of code:

if (field1!= "") {
Serial.println("field1 not blank...");
String MDC = "MD" + '\t' + field1;
Serial.println(MDC);
}

field1 has the value "MEXICO" and was valued from the strtok command parsing a inputstring. The strtok works fine, 3 fields were parsed like it should have been.

I was expecting my Serial Monitor to show: MD MEXICO instead I am getting the following;

from Serial Monitor: field1 not blank...
from Serial Monitor: 1: [MEXICO

Any ideas why when I Serial.println the MDC variable it is getting messed up?

Any ideas why when I Serial.println the MDC variable it is getting messed up?

Yes. != or == is NOT how you compare strings. strcmp() is.

...and there is no reason to make one big String for printing. Just print the pieces:

    Serial.print( "MD\t" );
     Serial.println( field1 );

That's it. it does not like the '\t'. Once I changed those to "\t" the code works fine.

I thought when using special characters you used single quotes and strings use double quote...

Thanks for the input.

Single quotes is a character, I do not know if the C++ String class excepts characters, probably only strings.