rectangletangle rectangletangle - 1 year ago 116
C++ Question

How do I change the case of a string in C++?

I have a string that may contain numbers as well as upper and lower case letters. I need to convert all the uppercase letters to lowercase and vice versa. How would one go about this?

Answer Source

Iterate the string and use isupper() to determine if each character is uppercase or not. If it's uppercase, convert it to lowercase using tolower(). If it's not uppercase, convert it to uppercase using toupper().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download