Interesting. I never got used to the C++ stream way of string output. I always use sprinft. You can control exactly what format you output and in how many digits, a must-have if you have limited space such as an lcd.
Examining the output from memoryFree returns the same value (1774) in both cases. I acknowledge that temporaries may use a few extra bytes, but I think that if you are that close to running out of memory that you cannot afford a few bytes of temporary stack space, you have quite big problems.
int memoryFree()
{
extern unsigned long __bss_end;
extern void *__brkval;
int freeValue; // currently bottom of memory
if (__brkval == 0)
return ((unsigned long)&freeValue) - ((unsigned long)&__bss_end);
return ((unsigned long)&freeValue) - ((unsigned long)__brkval);
}//end memoryFree()
liudr:
Interesting. I never got used to the C++ stream way of string output. I always use sprinft. You can control exactly what format you output and in how many digits, a must-have if you have limited space such as an lcd.
Indeed.
However it is more of a memory hog:
Sketch with this in it takes 3710 bytes of program memory:
Well,
I'll have to rewrite sprintf then. It's hard to change one's habits. Every day I go to my lecture hall, all my students sit almost exactly at their same seats. They even wait outside at their usual spots. Maybe it's "Ground Hog's Day" for me for the last semester. That could be why I was so tired the entire time.