目录

toupper

描述 (Description)

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

声明 (Declaration)

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

C++98

	
char_type toupper (char_type c) const;

C++11

char_type toupper (char_type c) const;

参数 (Parameters)

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

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

返回值 (Return Value)

它返回c的大写等价物。

异常 (Exceptions)

如果抛出异常,则facet对象中没有更改,但范围中的字符可能已受到影响。

数据竞争 (Data races)

访问该对象以及[低,高]范围内的元素。

例子 (Example)

在下面的例子中解释了std :: ctype :: toupper。

#include <iostream>
#include <locale>
int main () {
   std::locale loc;
   char site[] = "iowiki.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 iowiki.com as an uppercase is: T
The result of converting iowiki.com to uppercase is: iowiki.com
↑回到顶部↑
WIKI教程 @2018