Converting a String to Upper Case in C
Within the vast realm of programming, string manipulation holds immense importance. Among the myriad string manipulation tasks, the conversion of strings to upper case is a common requirement.
How to Convert a String to Upper Case
In the context of C , the
#include <algorithm> #include <string> std::string str = "Hello World"; std::transform(str.begin(), str.end(), str.begin(), ::toupper);
Breaking Down the Code
In this specific instance, the code performs the following steps:
Calls std::transform and specifies three essential arguments:
The transformation is performed in-place, effectively converting the characters within the str string to upper case.
Output
Assuming successful execution, the str string now holds the value "HELLO WORLD."
The above is the detailed content of How to Convert a String to Uppercase in C ?. For more information, please follow other related articles on the PHP Chinese website!