Why doesn't the following program change a sentence to uppercase?
#include <iostream>
#include <string>
using namespace std;
int main()
{
char name[20];
cout << "what is your name?" << endl;
system("pause");
cin.get(name, 20);
name[20] = toupper(name[20]);
cout << "Your name is " << name<< endl;
system("pause");
}
To change a
string
to upper case, you can usestd::transform
: