Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
locale
has_facet
isalnum
isalpha
iscntrl
isdigit
isgraph
islower
isprint
ispunct
isspace
isupper
isxdigit
locale
tolower
toupper
use_facet
standard facets:
codecvt
codecvt_base
codecvt_byname
collate
collate_byname
ctype
ctype_base
ctype_byname
messages
messages_base
messages_byname
moneypunct
moneypunct_byname
money_base
money_get
money_put
numpunct
numpunct_byname
num_get
num_put
time_base
time_get
time_get_byname
time_put
time_put_byname
ctype
ctype::ctype
public member functions:
ctype::is
ctype::narrow
ctype::scan_is
ctype::scan_not
ctype::tolower
ctype::toupper
ctype::widen
public member types:
ctype::char_type
ctype::mask
protected members:
ctype::do_is
ctype::do_narrow
ctype::do_scan_is
ctype::do_scan_not
ctype::do_tolower
ctype::do_toupper
ctype::do_widen
ctype::~ctype


ctype::toupper

public member function
       charT toupper (charT c) const;
const charT* toupper (charT* low, const charT* high) const;

Convert to uppercase

The first version returns the uppercase equivalent to c. If no such equivalent character exists, the value returned is c unchanged.

The second version replaces any lowercase caracters in the range [low,high) by its uppercase equivalent.

During its operation, this function simply calls the virtual protected member ctype::do_toupper, which is the member function in charge of performing the actions described above.

A global function with the same name (toupper) exists with the same behavior as the first version of this member function.

Parameters

c
Character to convert.
charT is the template parameter of ctype (i.e., the facet's character type).
low, high
Pointer to the initial and final characters of the sequence. The range used is [low,high), which contains all the characters between low and high, including the character pointed by low but not the character pointed by high.
charT is the template parameter of ctype (i.e., the facet's character type).

Return value

The first version returns the uppercase equivalent of c, or c itself if no such equivalent exists.

The second version returns high.

charT is the template parameter of ctype (i.e., the facet's character type).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// ctype::toupper example
#include <iostream>
#include <locale>
using namespace std;
int main ()
{
  locale loc;
  char site[] = "cplusplus.com";
  cout << "The first letter of " << site << " as an uppercase is: ";
  cout << use_facet< ctype<char> >(loc).toupper ( *site );
  cout << "\n";
  cout << "The result of converting " << site << " to uppercase is: ";
  use_facet< ctype<char> >(loc).toupper ( site, site+sizeof(site) );
  cout << site << "\n";
  return 0;
}


Output:

The first letter of cplusplus.com as an uppercase is: C
The result of converting cplusplus.com to uppercase is: CPLUSPLUS.COM

See also