tolower
描述 (Description)
它转换为小写和内部,此函数只调用虚拟保护成员do_tolower,默认情况下在通用模板和char特化(ctype
声明 (Declaration)
以下是std :: ctype :: tolower的声明。
C++98
char_type tolower (char_type c) const;
C++11
char_type tolower (char_type c) const;
参数 (Parameters)
m - 它是成员类型掩码的位掩码。
low,high - 它是指向字符序列的开头和结尾的指针。
返回值 (Return Value)
它返回c的小写等价物(如果不存在小写等效,则返回c)。
异常 (Exceptions)
如果抛出异常,则facet对象中没有更改,但范围中的字符可能已受到影响。
数据竞争 (Data races)
访问该对象以及[低,高]范围内的元素。
例子 (Example)
在下面的例子中解释了std :: ctype :: tolower。
#include <iostream>
#include <locale>
int main () {
std::locale loc;
char site[] = "iowiki.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;
}
让我们编译并运行上面的程序,这将产生以下结果 -
The first letter of iowiki.com as a lowercase is: t
The result of converting iowiki.com to lowercase is: iowiki.com