you need to use sprintf() and a pre-defined character buffer.
However, keep in mind the limited amount of RAM of the arduino makes strings like you suggest problematic. Large char const* like those get copied into RAM and cause problems.
I under stand what you are saying about the RAM, does it free it back up after it prints the line or save it till it does the entire code. If it does the entire code I will not be able to do it since the HTML code is several hundred lines and most of them will have variables.
Ok I will keep the memory problem in mind, but my issue at the moment is how to stick a variable in line wit the other code. As shown above, Anyone got any way to do that?
02660:
Ok I will keep the memory problem in mind, but my issue at the moment is how to stick a variable in line wit the other code. As shown above, Anyone got any way to do that?
I could tell you that (and James already did) but bear in mind you probably need to print literals differently from variables for the memory reasons discussed.
... does it free it back up after it prints the line or save it till it does the entire code ...
String literals (like "foo") are copied from the program memory into RAM. They are never freed.
However if you use the PROGMEM library, you can copy them a byte at a time, and only therefore use a total of one byte of RAM to hold them.
Ok, I get it now 8)
Now I understand why you were bringing up the RAM problem, I did not look into how sprintf() solved the problem till after my last post. Once I did I see why it will not work for what I need (in total)
I took a couple of minutes to play with 02660's problem and wrote this test code to run on my desktop:
(non-working code deleted)
I thought I was being more helpful than I was. I got help with the problems I was having (in a separate thread: Compiling data into program memory...) and posted the working version of the deleted code there.