Serial.print - how do I do strings and variables all in one line?

Hey all,

I'm currently doing something like

    Serial.print("something: ");
    Serial.print(something);
    Serial.print("\t");
    Serial.print("somethingelse: ");
    Serial.print(somethingelse);
    Serial.print("\t");
    Serial.print("\n");

I'd like to do this in one line, but doing it as "Serial.print(something . "\t something else" . somethingelse . "\t\n")" doesn't seem to work, same with using + to combine it to the same line. Maybe I'm missing something obvious?

Search for sprintf

Or the Streaming library.

Which is here: Streaming | Arduiniana

The below is the Streaming example. Doesn’t seem to want to compile.

#include <Streaming.h>

void setup()
{
  Serial.begin(9600);
  int lettera = 'A';
  int month = 4, day = 17, year = 2009;
  
  Serial << "This is an example of the new streaming" << endl;
  Serial << "library.  This allows you to print variables" << endl;
  Serial << "and strings without having to type line after" << endl;
  Serial << "line of Serial.print() calls.  Examples: " << endl;
  
  Serial << "A is " << lettera << "." << endl;
  Serial << "The current date is " << day << "-" << month << "-" << year << "." << endl;
  
  Serial << "You can use modifiers too, for example:" << endl;
  Serial << _BYTE(lettera) << " is " << _HEX(lettera) << " in hex. " << endl;
}

void loop()
{}

Hard to help you unless you specify the error.
I can tell you that the code in question compiles both on arduino 1.0.3 (openSUSE Linux 12.3) and on ArduinoDroid on my Galaxy S3. It also runs (would be nice to add a _CHAR type).

Do you believe your development environment works correctly? If not, fix that first.

I have caught errors in downloaded code (and the two environments I mentioned differ in what errors they catch). Generally you can expect examples to work.

Solved, don't keep the Streaming folder in the Streaming5 folder.