11 years, 9 months ago.

cout again - Where do de characters go? Why

Most times we output with pc.printf where pc is programmed to be connected to USBRx/TX.

But I can also use cout, without defining that that should go to USBRx/Tx. The message is showed in the terminal window because its COM is connected to USBTx/Rx. This is my question: cout apparently goes "by standard" to USBTx. Where and how is that "standard" defined? How to change that?

#include "mbed.h"
#include <iostream>
int main()
{
    cout << "cout goes to USBTx.\n Where and how is that defined?\n How to change that?" << endl;
}

1 Answer

11 years, 9 months ago.

stdout defaults to the USB connection, even if it isnt defined. You can also use printf instead of pc.printf, that will also work. It can be changed with freopen, see for example: http://mbed.org/forum/mbed/topic/267/?page=1#comment-4087

Accepted Answer

That is a perfect answer! Thanks. BTW, I think you point at vital information that should be here: https://mbed.org/handbook/Homepage or here: https://mbed.org/handbook/mbed-library-internals

posted by Geert Hospers 12 Mar 2013