I've got a pretty simple question. I'm trying to ask the player for to choose a difficulty. I want the case to be to not affect his choice, so I am using the toupper() function. Unfortunately, when I try to return the value of the difficulty, no matter what difficulty I choose, I receive 2009768935. However, when I enter an answer is all caps, avoiding the use of the toupper() function, everything turns out great.
Here is my code.
cout << "Choose a difficulty among Easy, Intermediate, and Hard.";
string x;
int difficulty;
cin >> x;
for (int i =0; i <=12; i++)
{ x[i] = x[toupper(i)]; }
if (x == "EASY" )
{ difficulty = 0; }
if (x == "INTERMEDIATE" )
{ difficulty = 1; }
if (x == "HARD" )
{ difficulty = 2; }
cout << difficulty;