Well, there's a lot of things going on here that are wrong.
1) word should be a string, not a character; explained in the second point
2) the number function should return a string (characters are single-letter entities, and you want to deal with words here, not single letters)
3) each case should, instead of saying the number as a word, return the number as a word. So replace this:
1 2
|
cout << "one" << endl;
break;
|
with this:
return "one";
since your number function returns a string (or at least now does since you've followed point 2; previously, it returned a character) and if it doesn't return anything, that means that when you go in to display the contents of word on line 15, it will have gibberish inside.
4) The reason why your switch statement fails is because each of your cases is checking the integer input (say, 1) against a character ('1'). 1 is different from '1' is different from "1"; first is an integer, second is a character, third is a string. Get rid of the single quotes if you want the cases to be integers instead of characters.
5) Your default case should return "an invalid number" or something to deal with the newly-revised system of returning strings instead of displaying them in the function that should return strings.