C++ 本地化库 - tolower



描述

它将字符转换为小写,内部,此函数简单地调用虚拟保护成员 do_tolower,在泛型模板和 char 特化 (ctype<char>) 中,默认情况下都会执行上述操作。

声明

以下是 std::ctype::tolower 的声明。

C++98

	
char_type tolower (char_type c) const;

C++11

char_type tolower (char_type c) const;

参数

  • m − 它是成员类型 mask 的位掩码。

  • low,high − 它是指向字符序列的开头和结尾的指针。

返回值

它返回 c 的小写等价物(如果不存在小写等价物,则返回 c 本身)。

异常

如果抛出异常,则方面对象不会发生更改,尽管范围内的字符可能已受影响。

数据竞争

访问对象和范围 [low,high) 中的元素。

示例

下面的示例解释了 std::ctype::tolower。

#include <iostream>
#include <locale>

int main () {
   std::locale loc;

   char site[] = "Tutorialspoint.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 Tutorialspoint.com as a lowercase is: t
The result of converting Tutorialspoint.com to lowercase is: tutorialspoint.com 
locale.htm
广告
© . All rights reserved.