how to convert a int ( or unsigned char )

Discussion in 'C Programming' started by Andre, Dec 19, 2012.

  1. Andre

    Andre Guest

    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
    Andre, Dec 19, 2012
    #1
    1. Advertising

  2. 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. :)
    Bjorn Augestad, Dec 19, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timo Freiberger
    Replies:
    3
    Views:
    919
    Bob Hairgrove
    Oct 30, 2004
  2. Hal Styli
    Replies:
    14
    Views:
    1,604
    Old Wolf
    Jan 20, 2004
  3. er
    Replies:
    6
    Views:
    467
    Andre Kostur
    Sep 14, 2007
  4. ciccio

    int*unsigned int = unsigned?

    ciccio, Jun 4, 2010, in forum: C++
    Replies:
    2
    Views:
    387
    Öö Tiib
    Jun 4, 2010
  5. pozz
    Replies:
    12
    Views:
    700
    Tim Rentsch
    Mar 20, 2011
Loading...

Share This Page