Prints the value of a number, or a string, to the stream.
The character to be sent to the stream.
The string, in RAM, that you want to print to the stream.
The integer number you want to print to the stream.
The real number you want to print to the stream.
The number base you want to use for the number. ie 10=decimal, 16=hexadecimal, 2=binary, 8=octal.
The number of decimal places to be shown to the right of the decimal point.
Reference to another stream.
The name of the sensor that you want to dump to the stream.
When you run the code generation in Project Designer you can define the standard output and standard error destinations. WebbotLib will automatically define the following streams to those devices:-
cout - An output stream to the 'standard output' device.
cin - An input stream from the 'standard output' device.
err - An output stream to the 'standard error' device.
// Print stuff to the standard output device
cout.print(12.3456); // default to 2 decimal places
cout.print(12.3456,4); // uses 4 decimal places
cout.print( 'A' );
// Copy all incoming data to standard out
cout.print( cin );
// Dump the sensor called 'myCompass'
cout.print( myCompass );
You can also call the print routine multiple times:
cout.print("The answer is ").print(12);
Streams also support the '<<' operator:
cout << "The answer is " << 12;
cout << "myCompass readings: " << myCompass;