include "0" in parseInt

im using parseInt to extract a variable from a sdcard txt file.. part of code below.

p1 = parseInt();
t1 = parseInt();

heres what inside text file


p1 returns a value: 10
t1 returns a value: 5

is there a way "t1" can return a value: 05 instead of just 5 only?

im printing the values on a LCD.. so i need 05 to be 2 digits.. so it will align with p1 value 10 like this:


right now it shows like this:


You can, of course, test what you are printing and if is less than 10 print a zero before it.

You are parsing integers. The integer 05 is the same as 5. If you want to read them in as strings, then you will get “10” and “05”

If you do need integers, then, when you display them, you have to inject a leading 0 if you want it

if(val < 10) lcd.print("0");

The same is true if your values ever get above 99.

if(val < 10) lcd.print("0");

Nice! thanks!

Unless t1 is a time (minute or second), the usual practice is to print leading spaces, not leading 0s, when the value is less than the desired field width.