HiveBrain v1.2.0
Get Started
← Back to all entries
snippetcppCritical

Convert a String In C++ To Upper Case

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
stringconvertcaseupper

Problem

How could one convert a string to upper case. The examples I have found from googling only have to deal with chars.

Solution

Boost string algorithms:

#include 
#include 

std::string str = "Hello World";

boost::to_upper(str);

std::string newstr = boost::to_upper_copy("Hello World");

Code Snippets

#include <boost/algorithm/string.hpp>
#include <string>

std::string str = "Hello World";

boost::to_upper(str);

std::string newstr = boost::to_upper_copy<std::string>("Hello World");

Context

Stack Overflow Q#735204, score: 228

Revisions (0)

No revisions yet.