Converting an int to an address in an array

This is a discussion on Converting an int to an address in an array within the C Programming forums, part of the General Programming Boards category; Originally Posted by vart so the 'n' should be outputed as 0x32? or your input is limited to digits? also ...

  1. #16
    Registered User
    Join Date
    Mar 2009
    Posts
    6
    Quote Originally Posted by vart View Post
    so the 'n' should be outputed as 0x32?

    or your input is limited to digits?

    also - the result should be string or array of integer values? What will be sent to display registers?
    Yes, exactly. Just an array of hex values sent to the display register.
    To output 51 to the screen I would write 0x05 (the number 5) to DISPLAY_DATA_IN,
    then 0x00 (for example) for the character position register. To get the remaining 1 value I would write 0x01 to DISPLAY_DATA_IN then 0x01 to the character position register.

    Eventually I may want to do this for all characters on the table, but we definitely need to interpret integers in the mean time.

  2. #17
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    so you need ints...

    for chars '0' - '9'

    int x = ch - '0';

    will give 0 - 9 (or 0x00 - 0x 09 which is the same for integers)


    then if(x == 0) x += 10; (or x += 0x0A; if you prefer hex notation)

    and then sent x to register - do it for each digit...

    when you'll want to process more chars - do a convertion table that will contain values like

    table['n'] == 0x32;

    table size will be 255 - you you do not need to search on it - just direct access using char value as index
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. NEED HELP READING FILE and PRINTING
    By geoffr0 in forum C Programming
    Replies: 4
    Last Post: 04-16-2009, 06:26 PM
  2. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 01:13 AM
  3. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 06:20 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21