C++ 本地化库 - toupper



描述

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

声明

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

C++98

	
char_type toupper (char_type c) const;

C++11

char_type toupper (char_type c) const;

参数

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

  • low,high − 它是指向字符序列的起始和结束位置的指针。

返回值

它返回 c 的大写等价字符。

异常

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

数据竞争

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

示例

以下示例说明了 std::ctype::toupper。

#include <iostream>
#include <locale>

int main () {
   std::locale loc;

   char site[] = "Tutorialspoint.com";

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

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

   return 0;
}

让我们编译并运行以上程序,这将产生以下结果:

The first letter of Tutorialspoint.com as an uppercase is: T
The result of converting Tutorialspoint.com to uppercase is: TUTORIALSPOINT.COM
locale.htm
广告

© . All rights reserved.