Changing a string input to capital letters

I've got the single character input to change to caps but can't get it to change when the user inputs a word guess

void compareguess(string& aster, string getword, int& guesses)
{
string userguess;
int totalscore = ((getword.length()) + 1) - guesses;
for (int i = 0; i < getword.length() + 110; i++){
cout << "Enter a letter or a guess... ";
cin >> userguess;
if (userguess.length() == 1){
char c = toupper(userguess.at(0));
for (int i = 0; i < getword.length(); i++){
if (c == getword.at(i))
{
aster.replace(i, 1, 1, c);
guesses + 1;
}
}

cout << "guessed: " << c << endl;
cout << "masked word: " << aster << endl;
}

else if (userguess == getword)
{
cout << "Well done!" << endl;
cout << "guessed: " << userguess << endl;
cout << "The word was: " << getword << endl;
cout << totalscore << endl;
}

else{
cout << "Wrong word!" << endl;
guesses + 1;

}
}
cout << "You ran out of guesses" << endl;
cout << "The word was: " << getword << endl;
cout << "You get 0 points" << endl;

}
How about this:

1
2
for (unsigned short i=0; i <=  getword.length () - 1; i++)
            getword.at (i) = toupper (getword.at(i));


or if you just need to change first char (if I understand you right)

getword.at(0) = toupper (getword.at(0);
Topic archived. No new replies allowed.