I have a string: \"apple\"
. How can I convert only the first character to uppercase and get a new string in the form of \"Apple\"
?
I can al
(Only works with 'ASCII' characters.)
std::wstring s = L"apple";
if(islower(s.at(0) <= 'z' ? s.at(0) : 'A'))
s[0] += 'A' - 'a';
Or if you are feeling fancy and feel like torturing any future readers of your code:
std::wstringstream wss;
wss << std::uppercase << s[0]
<< std::nouppercase << s.substr(1);
wss >> s;