answersLogoWhite

0

To change any string to uppercase, loop through each character in the string. If the character is in the range 'a' through 'z', decrement the character by decimal 32 (the difference between ASCII value 'a' and 'A'). The following function shows an example of this:

void to_upper(std::string& str)

{

for(int i=0; i<str.size(); ++i)

if(str[i]>='a' && str[i]<='z')

str[i]-=32;

}

User Avatar

Wiki User

11y ago

Still curious? Ask our experts.

Chat with our AI personalities

ReneRene
Change my mind. I dare you.
Chat with Rene
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
ProfessorProfessor
I will give you the most educated answer.
Chat with Professor

Add your answer:

Earn +20 pts
Q: Changing a word to all uppercase letters in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp