if I have a string like "toenuts" and I had have "t" an integer and made it equal 2, then how can i convert that "toenuts[0]" into an integer so that it will equal 2? Do i just use istringstream? atoi?
Sorry, I don't understand the question. Do you mean you want to change "toenuts" to "2oenuts"? Or create a function that takes "toenuts" as a parameter and returns 2? If you mean that latter, what rules should the function use? In other words, how would the function know to return 2 instead of 7?
So you want to map specific characters to specific ints?
This might help you:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include <string>
int main()
{
//Using characters from top half of ASCII table will lead to undefined behavior
int char_map[128] = {0}; //All characters are set to 0
char_map['t'] = 2; //Set 't' to 2.
std::string s = "toenuts";
for(char c: s)
std::cout << char_map[c];
}