Link to home
Start Free TrialLog in
Avatar of ChristopherNoel
ChristopherNoel

asked on

how to covert a numeric to a character string

i been doing a project about a user menu..
i wonder how to convert a numeric to a character string
er...sorry about that, wat i really want to ask is for example if i key in a numeric number 3 then the
output will be a character "three" anf if i key in 4 it will return a character string "four". i wondder
what string library should used..
Avatar of pjknibbs
pjknibbs

Not sure entirely what you mean. If you're asking how you can convert a number stored in an integer (e.g. 25343) to a printable string, then you're looking at sprintf() or _ltoa (the latter might possibly be compiler-specific, I'm not sure). If this ISN'T what you're asking I think you need to clarify the question.
Avatar of ChristopherNoel

ASKER

er...sorry about that, wat i really want to ask is for example if i key in a numeric number 3 then the output will be a character "three" anf if i key in 4 it will return a character string "four". i wondder what string library should used..
What is the range of numbers?
2 ChristopherNoel
What is the big problem. Let's create an arrays with text description and parse the number in the correct range.
{"zero","one","two",..,"nine"};
{"eleven", "twelve", "thirteen",..., "nineteen"}
{"ten","twenty",..."ninety"}
{"hundred", "thousand", "million"}
I think it is standard task for students.
Well, there isn't a standard library function to do what you want, so you'll have to write your own. AlexNek has pointed you along the right path, I suspect.
ASKER CERTIFIED SOLUTION
Avatar of Vasudeesha
Vasudeesha

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi ChristopherNoel

Please convert the above program...
....
....
....
char *a[5] = { " Hundred", " Thousand", " Lakhs", " Crore", " Arab" } ;

      ----------To---------

char *a[5] = { " Hundred", " Thousand", " Million", " Million", " Trillion" } ;

The above Numbering system we use in India... You can change to your country's format ..


Bye
Vasudeesha
Avatar of Kent Olsen
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:
Accept Vasudeesha's comment as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Kent (Kdo)
EE Cleanup Volunteer