c++ number conversion
Community Forums/General Help/c++ number conversion
| ||
Hi I'm currently learning c++ and trying to make a program as simple as possible to convert int numbers into words e.g. 568 = five hundred and sixty eight, but only problem is i'm not to sure of how to go about getting 1: it to be as short as possible 2: how to get it word values above 19, 100 ect can anyone help with advice and possible code samples? Thank you. |
| ||
There is a post in the code archives that does this, I believe... |
| ||
Store the Strings in an array. Use a for loop incremented by 100, the a seperate one by 10, and then by one. NOT C++: for i=0 to 100 i=i+99 if number > i print strings-hundreds(i) next ... repeat with 10s |
| ||
Here is the code archive function to do it in Blitzmax... You should be able to take the logic and do it in c++. http://www.blitzmax.com/codearcs/codearcs.php?code=1300 |
| ||
thanks :) should be able to work it out from the code and advice. |