Quote Originally Posted by Rafen View Post
I just can't seem to figure out how exactly to do it. I am just guessing and can't figure out how exactly to do it.
Regardless of the number, you should extract all the digits (this is assuming the number is between 1 and 999, and it's this range you should put the most time in).

As to your code:
1) Even if the hundreds, tens, or units place is 0, you extract that value.
2) Your code does not extract the hundreds digit.
3) You don't need to make the input a string. Make it an integer and use cin, not getline().
4) Please create your arrays of names I stated above.
Code:
const char *unitName[] = {"zero", "one", "two", /* ... */, "nine"};
const char* tensNames[] = {"ten", "twenty", "thirty", /* ... */, "ninety"};
const char* teensNames[] = {"eleven", "twelve", /* ... */, "nineteen"};
Once you have 1) and 4) staring at you, it shouldn't take a long time to write the logic to print the correct number. For example, If the hundreds digit is > 0, then you know you need to do a lookup in the units array for the hundred's digit name, and then print the word "hundred" after it. That's as far as I'm going to help you