My goal is to input a number as a string into a function and return its value as an integer. For example, if "three" is the input, then 3 would be the output. I am having troubles figuring out how to actually return the integer. Here is what I have so far.
void strToNum (string& what) {
map<string, int> mp;
mp["one"] = 1;
mp["two"] = 2;
mp["three"] = 3;
mp["four"] = 4;
mp["five"] = 5;
mp["six"] = 6;
mp["seven"] = 7;
mp["eight"] = 8;
mp["nine"] = 9;
mp["zero"] = 0;
return mp[what];
}
VSCode is telling me "return value type does not match the function type". Adding a type (void, string) before "what" has not helped.
