This has got to be the easiest thing to do in C++.
..and I know it’s been asked many many times before, however please keep in mind that this is part of an Arduino project and memory saving is a major issue as I’ve only got 32256 byte maximum to play with.
I need to convert an integer to a string.
int GSM_BAUD_RATE;
GSM_BAUD_RATE = 4800;
Serial.println("GSM Shield running at " + GSM_BAUD_RATE + " baud rate.");
Obviously the last line is going to give me an error.
Thanks in advance.
If, as it seems, you are working on an Arduino project, you should simply let the
Serialobject deal with it:since the
printandprintlnmethods have overloads to handle several different types.The other methods can be useful on “normal” machines, but stuff like
stringandostringstreamrequire heap allocation, which, on an Arduino board, should be avoided if possible due to the strict memory constraints.