public member function
<locale>

std::ctype::tolower

single character (1)
       char_type tolower (char_type c) const;
sequence (2)
const char_type* tolower (char_type* low, const char_type* high) const;
Convert to lowercase
The first version (1) returns the lowercase equivalent of c. If no such equivalent character exists, the value returned is c, unchanged.

The second version (2) replaces any uppercase characters in the range [low,high) with its lowercase equivalent.

Internally, this function simply calls the virtual protected member do_tolower, which does the above by default in both the generic template and the char specialization (ctype<char>).

A non-member function with the same name (tolower) exists with the same behavior as (1).

Parameters

c
Character to convert case.
Member type char_type is the facet's character type (defined as an alias of ctype's template parameter, charT).
low, high
Pointer to the beginning and end of the sequence of characters. 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.
Note that null characters (if any) are also considered, and the function proceeds beyond them, until the entire range is converted.
Member type char_type is the facet's character type (defined as an alias of ctype's template parameter, charT).

Return value

The first version (1) returns the lowercase equivalent of c (or c unchanged if no lowercase equivalent exists).

The second version always returns high.

Member type char_type is the facet's character type (defined as an alias of ctype's template parameter, charT).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// ctype::tolower example
#include <iostream>       // std::cout
#include <locale>         // std::locale, std::ctype, std::use_facet

int main ()
{
  std::locale loc;

  char site[] = "CPlusPlus.com";

  std::cout << "The first letter of " << site << " as a lowercase is: ";
  std::cout << std::use_facet< std::ctype<char> >(loc).tolower ( *site );
  std::cout << '\n';

  std::cout << "The result of converting " << site << " to lowercase is: ";
  std::use_facet< std::ctype<char> >(loc).tolower ( site, site+sizeof(site) );
  std::cout << site << '\n';

  return 0;
}

Output:

The first letter of CPlusPlus.com as a lowercase is: c
The result of converting CPlusPlus.com to lowercase is: cplusplus.com


Data races

The object is accessed.
In (2), the elements in the range [low,high) are accessed and modified.

Exception safety

If an exception is thrown, there are no changes in the facet object, although characters in the range (2) may have been affected.

See also