Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   how to convert a int ( or unsigned char ) (http://www.velocityreviews.com/forums/t955642-how-to-convert-a-int-or-unsigned-char.html)

Andre 12-19-2012 10:53 AM

how to convert a int ( or unsigned char )
 
to a strings of char??
such as would
printf("%d",xx); do or better scanf(..)
I can't use scanf as I am running this on a PIC16F877 and I am short of
memory.
traget is to display time and temperature on a LCD, time being available
as long UTC;
Any idea??
Many thanks in advances.
Andre

Bjorn Augestad 12-19-2012 08:37 PM

Re: how to convert a int ( or unsigned char )
 
Den 19.12.2012 11:53, skrev Andre:
> to a strings of char??
> such as would
> printf("%d",xx); do or better scanf(..)
> I can't use scanf as I am running this on a PIC16F877 and I am short of
> memory.
> traget is to display time and temperature on a LCD, time being available
> as long UTC;
> Any idea??
> Many thanks in advances.
> Andre


How about something like this untested snippet:
char s[3];
unsigned hour = some_value_between_0_and_23;

s[0] = hour / 10 + '0';
s[1] = hour % 10 + '0';
s[2] = '\0';

display_hour_on_LCD(s);
...

Same for minutes and temperatures. :)



All times are GMT. The time now is 10:08 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.