std::ohserialstream cout(Serial) print issue

Hi guys,

I was wondering if you can give me a hand with a printing issue i’ve been having with IDE 1.6.7 and Atmel 7 with andy STD lib 1.2, the thing is every time i try to print with ohserialstream it only prints the first two characters. I’ve seen similar post without any solutions (http://forum.arduino.cc/index.php?topic=302592.0), any idea?. In this case it onle prints “He”.

#include
#include
#include
#include
#include <pnew.cpp>

using namespace std;

namespace std
{
ohserialstream cout(Serial);
}

vector strings;

void setup(void)
{
Serial.begin(115200);

strings.push_back(“Hello,”);
strings.push_back(“world!”);
copy(strings.begin(),strings.end(),ostream_iterator(cout," "));
cout << endl;
}

void loop(void) { }

That's an incredibly complicated way to avoid using Serial.print(). Good luck.

Hi Paul,

Serial.print() doesnt allow me to print std::string variables.

Regards

Serial.print() doesnt allow me to print std::string variables.

A std::string wraps a NULL terminated char array. Surely, there is some method of getting at the string that the std::string wraps, like c_str().

Hey Paul,

Thanks for replying but i could make it work, im kinda a newby but...

It seems that andy's std doesnt work with newer IDE, it was designed i think for 1.0.x. I tested StandardCPlusPlus that someone added some features from andys and works like a charm with IDE 1.6.7

https://github.com/mjs513/FreeIMU-Updates/tree/master/libraries/StandardCplusplus

For anyone using recent IDE and needs std vectors or other std libs.

Regards.