This article explains how sprintf and memcpy functions work.
We will make a memory buffer in three steps adding on it more and more objects, of course in RAM , usisng sprintf function and then we will copy this buffer to an other memory space using memcpy function. So, have a look at Keil memory manipulation routines.
The example C code is here.
The C code exports at Hyperterminal (at 19,200 kbaud) the total number of characters that are inside the buffer after each one executed addition step that we have done using sprintf. Also it prints the characters that are inside the buffer via ASC0 using puts function. The objects are stored in buffer as strings so it is counted and the \0 character.
After it the code prints the content of the new buffer that we made using memcpy.
See the result.
* At step three you have to add +2 at the total number of counted chasracters because we added and the string "-+$" terminated with \0.
* ASC0.C file needs line 175 to be added outside DAVE .
Exercise: what is doing this line?