Docedison:
And where does A, B, and C get changed...
This:
char d = ('%s : %s : %s', a, b, c);
Is Not going to do much..
Bob
I have a loop which gives me a, b, c i just simplified the code so that everyone can understand easily...
marco_c:
char d = ('%s : %s : %s', a, b, c);
is incorrect.
char s[10];
sprintf(s, "%d:%d:%d", a, b, c);
lcd.print(s);
use %02d to get 2 digits always.
Hi marco_c
it works perfectly,thanks,
but i just have a question regarding s[10], correct me if i'm wrong it's an array with 10 data storage, {1,2,3,4,5,6,7,8,9,10},
but i'm not sure how does sprintf is using it,because i tried using s[0], and prints a=99,b=99, c=99, and it still outputs "99:99:99"
majenko:
marco_c:
use %02d to get 2 digits always.
That won't always give 2 digits
Put in a value of 193 and it will display 193. "%02d" is a minimum of 2 digits, padded with leading zeroes. Something to be aware of on an LCD where it could mess up your display formatting (not to mention potentially causing a buffer overflow) if you're not careful. To limit it to 2 digits you could "modulus" your values with:
snprintf(s, 9, "%02d:%02d:%02d", a % 100, b % 100, c % 100);
But of course, if you know that your values are never going to go above 99, then that's not a problem.
Thanks for this info...I've noted your tip..