Convert String to int

PaulS:
For transmission, a leading space takes up exactly the same amount of space. For use on the receiver, the leading space is much easier to deal with than a leading 0, because a leading 0 is how functions that convert strings to numeric values know that you want the number interpreted as an octal value.

It is unlikely that you will be sending values less than 100 as octal, while sending values greater than or equal 100 as decimal.

Unless you are really weird, that is.

HAHA I understood you :D, And yes I agree with you :slight_smile:

SurferTim:
I use sprintf() to convert data types to formatted strings. If you want a specific number of leading zeros, try this. It insures there are three characters, and if not, it adds the correct number of leading zeros.

int myInt = 12;

char outBuf[16];
sprintf(outBuf,"%03u",myInt);
Serial.println(outBuf);

Thanks a lot for your help! :smiley: that really helped me :slight_smile: