Thread: Numbers to Letters

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    3

    Question Numbers to Letters

    Can somebody tell me or give me help, point me in the right direction, on how i would take and an amount like $1452.34 and automatically print out "One Thousand Four hundred Fifty Two Dollars and Thirty Four Cents." I was thinking this would require alot of "if/else" statements, but how would i identify the different numbers and there position in the amount like thousands, hundreds and millions.

    Thanks for all the help, much appreciated.

  2. #2
    Registered User RussMan's Avatar
    Join Date
    Sep 2003
    Posts
    14
    Yes it would require a little bit of indirect seperating but first you need to convert the value to a string to pull it apart. One function that will do that is _itoa() it takes an integer and converts it to a string. Then you can rip the string apart to determine what is in it.

  3. #3
    root
    Join Date
    Sep 2003
    Posts
    232
    I remember seeing several threads along these lines while searching the forums. Methinks you should get into the searching habit as well, you'll save yourself having to wait for a response to a new thread.
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  4. #4
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Originally posted by twm
    I remember seeing several threads along these lines while searching the forums.
    Yes, there have been quite a few threads on this topic. The difference this time is the addition of the decimal point. Be careful with some of the code though, be sure to read the complete thread.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  5. #5
    root
    Join Date
    Sep 2003
    Posts
    232
    >The difference this time is the addition of the decimal point.
    I don't see much difference, you're working with two strings instead of one and the delimiter between the two is a period character. No biggie.
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  6. #6
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Originally posted by twm
    >The difference this time is the addition of the decimal point.
    I don't see much difference, you're working with two strings instead of one and the delimiter between the two is a period character. No biggie.
    Didn't say it was a biggie, just a slight difference.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Generate Random Numbers and Assign to Days of Week
    By mms in forum C++ Programming
    Replies: 10
    Last Post: 05-04-2006, 01:51 AM
  2. Replies: 4
    Last Post: 04-19-2005, 08:05 PM
  3. Line Numbers in VI and/or Visual C++ :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 02-10-2002, 10:54 PM
  4. Transforming letters to numbers...
    By N8760 in forum C++ Programming
    Replies: 2
    Last Post: 12-23-2001, 03:26 PM
  5. How do you allocate numbers to letters?
    By face_master in forum C++ Programming
    Replies: 9
    Last Post: 11-14-2001, 06:47 AM