Hi,
Some compilers may initialize variables to zero, but if they do, it is not something standard. Other compilers will
do nothing. It is up to the programmer to initialize variables. The microcontroller will have random garbage in RAM
locations upon power-up, so the programmer must always set RAM contents (i.e. variables) to the correct
initial value if it matters to the program.
It is tidier to use a for loop than a separate 'if' and an increment instruction at the end. The for loop defines it all
on the first line. Try your method a few times, nested, and you'll soon come to the same conclusion.
It may start from 1 until you initialize the code. Please re-post the code with your modifications, if it is still occurring.
Your 'numtostring' function shows you have a misunderstanding of what you're trying to do. If you want to convert
_from_ a number, why is your parameter that you are passing defined as 'unsigned char *s'?. Surely it should be
(say) just 'unsigned char', or 'int', or 'float' or something?
If you want to convert from a number to a decimal string, you need to check to see how many hundreds there are in the
number (by division) and print a character to represent the hundreds column, then see how many tens are remaining
in the number, print in the tens column and so on...
There is a ready-made function called sprintf() that does all that, if you search the forum you'll find info on it. However
it entails your C library supporting it, and I'm not familiar with your compiler.