Answers for "toupper stl cpp"

C++
3

string to upper c++

std::string data = "This is a sample string.";
// convert string to upper case
std::for_each(data.begin(), data.end(), [](char & c){
c = ::toupper(c);
});
Posted by: Guest on May-09-2020
0

c++ toupper string

// toupper example (C++)
#include <iostream>       // std::cout
#include <string>         // std::string
#include <locale>         // std::locale, std::toupper

int main ()
{
  std::locale loc;
  std::string str="Test String.n";
  for (std::string::size_type i=0; i<str.length(); ++i)
    std::cout << std::toupper(str[i],loc);
  return 0;
}

/*
Output:
TEST STRING.
*/
Posted by: Guest on February-16-2021

Browse Popular Code Answers by Language