concatenate print statements

Does anyone know if there is a way to concatenate print statements so you can have a string and a variable in a single Serial.print() statement?

I was wondering if there is something like what they have in Php: <?php echo "hello" . $name ?>


Nope, because in C a string isn't a built-in data type, so there are no string operators and it requires one or more function calls to get the stuff converted to strings and the strings concatenated. Technically, since were using C++, someone could write such a function and overload the "+" operator, but there's the whole library-vs-FLASH size thing when on an 8 bit microcontroller with 16k of program space.

If you find yourself doing this a bunch in a particular program, you can always use #define to create an "inline" function:

#define howdy(X, Y) {Serial.print((X)); Serial.print((Y));}


 howdy("hello ", username);


 howdy("goodbye ", username);