toupper <ctype.h> <cctype>
原文:https://www.cplusplus.com/reference/clibrary/cctype/toupper/
int toupper ( int c );
將小寫字母轉換成大寫字母
如果參數c是小寫字母,將參數c轉換成對應的大寫字母。如果不能轉換,則該參數保留原值不變。
請注意哪些字符被認為是字母依賴於當前正在使用的locale地區設置;在默認的c語言地區設置下,以下任何小寫字母中的一個:a b c d e f g h i j k l m n o p q r s t u v w x y z,都會被分別轉換成:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z。
在C++語言中,一個特定於語言環境模版版本的toupper函數存在於頭文件<locale>。
參數
c
待轉換的小寫字母,被轉換成一個整數或者EOF結束符。
返回值
參數c對應的大寫字母,或者未改變的參數c。這個值以int值返回,並且可以被強製轉換成char。
實例:
/* toupper example */ #include <stdio.h> #include <ctype.h> int main () { int i=0; char str[]="Test String.\n"; char c; while (str[i]) { c=str[i]; putchar (toupper(c)); i++; } return 0; }
輸出:
TEST STRING.
請參閱
tolower 將大寫字母轉換成小寫字母(函數)
islower 檢測字符是否為小寫字母(函數)
isupper 檢測字符是否為大寫字母(函數)
isalpha 檢查字符是否是字母(函數)
最後更新:2017-04-02 06:52:08