check and convert lower character to upper character

A

alessio211734

How can I check in c++ string if a character is lower or upper?
Exist a function in c++ to convert string to upper characters?


Thanks in advance.
 
O

oogie

How can I check in c++ string if a character is lower or upper?
Exist a function in c++ to convert string to upper characters?

Thanks in advance.

The isupper(), islower(), toupper(), and tolower() functions should
handle this. You will need to also include the cctype header in your
code.
 
J

Juha Nieminen

oogie said:
The isupper(), islower(), toupper(), and tolower() functions should
handle this.

Note that they might not handle correctly characters outside the ASCII
range (such as ä, ö, etc).
 
J

James Kanze

Note that they might not handle correctly characters outside the ASCII
range (such as ä, ö, etc).

It's locale specific.

Note, on the other hand, that you cannot reliably pass a char to
the isupper() et al. functions in <cctype> without risking
undefined behavior. For this, you need the functions in
std::locale::ctype<char> (which is probably the better way to do
it anyway, although it can be awfully verbose).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top