0

How do you convert something to uppercase in c++?

I need to validate some statement but I'm having trouble with validation uppercase I don't wanna create a set of vectors and check within them because I believe the is a function for it

23rd Apr 2020, 9:34 PM
Prosper Will Mambambo
Prosper Will Mambambo - avatar
1 Antwort
+ 4
You can use std::toupper() to convert a single character to uppercase: https://en.cppreference.com/w/cpp/string/byte/toupper You can apply it to an entire string via std::transform(): https://en.cppreference.com/w/cpp/algorithm/transform For a string 's', it would look like: std::transform ( s.begin(), s.end(), s.begin(), []( unsigned char c ) -> unsigned char { return std::toupper( c ); } );
23rd Apr 2020, 9:52 PM
Shadow
Shadow - avatar