CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

24hour clock display

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asjad



Joined: 09 Mar 2004
Posts: 52
Location: Greater Manchester - UK

View user's profile Send private message

24hour clock display
PostPosted: Fri Mar 12, 2004 8:28 am     Reply with quote

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




Razz
_________________
Best Regards
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 12, 2004 8:34 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Mar 12, 2004 8:38 am     Reply with quote

%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

View user's profile Send private message

PostPosted: Fri Mar 12, 2004 8:45 am     Reply with quote

asjad wrote:
%02U = %2U??

think it means the same thing, so I would still get the same output format

Thanks for replying though!!


Rolling Eyes
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

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 12, 2004 8:49 am     Reply with quote

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

View user's profile Send private message

Brilliant!!!
PostPosted: Fri Mar 12, 2004 8:52 am     Reply with quote

Thanks for replying.

IT WORKS!! Laughing
_________________
Best Regards
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 12, 2004 10:50 am     Reply with quote

Told you so....

Wink

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group