Looking through the String class.. I can find no way to access the buffer pointer. wth? I just want a c_str() like function, or a const char * operator. I can't believe this would be omitted from a string class. I must have missed something?
You can use the STL string class, rather than the Arduino String class:
#include <iterator>
#include <string>
#include <pnew.cpp>
void setup ()
{
std::string foo = "Hello, world";
Serial.begin (115200);
Serial.println (foo.c_str ());
}
void loop () {}
Binary sketch size: 2576 bytes (of a 32256 byte maximum)
Or you can use the String class:
void setup ()
{
String foo = "Hello, world";
Serial.begin (115200);
Serial.println (foo);
}
void loop () {}
Binary sketch size: 3522 bytes (of a 32256 byte maximum)
That uses quite a bit more memory, as you can see. Another 1000 bytes.
I didn't realize STL was available. Good info, thanks
You have to download and install it. Not a very big deal.
... copy all the files in the avr-stl\include directory into the hardware\tools\avr\avr\include subdirectory of the Arduino installation ...
@nick,
The link is not responding do you have a zip?
It seemed to work a minute ago, but I have a copy: