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
廣告