View previous topic :: View next topic |
Author |
Message |
asjad
Joined: 09 Mar 2004 Posts: 52 Location: Greater Manchester - UK
|
24hour clock display |
Posted: Fri Mar 12, 2004 8:28 am |
|
|
I am having trouble displaying a 24hour clock format: HH:MM
I have two variables int hrs and int min.
I have put:
lcd_init();
printf(lcd_putc, "%2U %2U",hrs min);
The %2U is a formatting code, where it reserves 2 fixed places for
a variable.
The output is like:
" 1 5" - if the zeros where in the right place it would look like "0105"
Any ideas???
I thank you in advance
_________________ Best Regards |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Fri Mar 12, 2004 8:34 am |
|
|
Try:
Code: |
printf(lcd_putc, "%02U%02U",hrs min);
|
_________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
asjad
Joined: 09 Mar 2004 Posts: 52 Location: Greater Manchester - UK
|
|
Posted: Fri Mar 12, 2004 8:38 am |
|
|
%02U = %2U??
think it means the same thing, so I would still get the same output format
Thanks for replying though!! _________________ Best Regards |
|
|
bwhiten
Joined: 26 Nov 2003 Posts: 151 Location: Grayson, GA
|
|
Posted: Fri Mar 12, 2004 8:45 am |
|
|
asjad wrote: | %02U = %2U??
think it means the same thing, so I would still get the same output format
Thanks for replying though!! |
You should try it. These are not the same when it comes to printf formats. |
|
|
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Fri Mar 12, 2004 8:49 am |
|
|
asjad wrote: | %02U = %2U??
think it means the same thing, so I would still get the same output format
Thanks for replying though!! |
You are wrong. |
|
|
asjad
Joined: 09 Mar 2004 Posts: 52 Location: Greater Manchester - UK
|
Brilliant!!! |
Posted: Fri Mar 12, 2004 8:52 am |
|
|
Thanks for replying.
IT WORKS!! _________________ Best Regards |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Fri Mar 12, 2004 10:50 am |
|
|
Told you so....
By the way, I suggest you get a copy of Kernighan & Ritchie's "C Programming Lanugage (2nd Edition)". A good investment.
ISBN: 0131103628
Look at amazon.com. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
|