Convert String to Uppercase or Lowercase Using STL in C++



In this tutorial, we will be discussing a program to understand conversion of whole string to uppercase or lowercase using STL in C++.

To perform this transformation, C++ STL provides toupper() and tolower() functions to convert to uppercase and lowercase respectively.

Example

 Live Demo

#include<bits/stdc++.h>
using namespace std;
int main(){
   string su = "Tutorials point";
   transform(su.begin(), su.end(), su.begin(), ::toupper);
   cout << su << endl;
   string sl = "Tutorials Point";
   transform(sl.begin(), sl.end(), sl.begin(), ::tolower);
   cout << sl << endl;
   return 0;
}

Output

TUTORIALS POINT
tutorials point
Updated on: 2020-03-16T09:47:51+05:30

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started