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