😸
[C] toupper 関数
機能
英字(アルファベット)の小文字を大文字に変換する標準ライブラリ関数。[1]
使用例
A
と表示する
\n
は改行を表す エスケープシーケンス[2]
コード
printf("%c\n", toupper('a'));
全文
#include <stdio.h>
#include <ctype.h>
void main() {
printf("%c\n", toupper('a'));
}
実行結果
A
HELLO
を変数から表示する
コード
char str[] = "hello";
for (int i = 0; str[i] != '\0'; i++) {
printf("%c", toupper(str[i]));
}
printf("\n");
全文
#include <stdio.h>
#include <ctype.h>
void main() {
char str[] = "hello";
for (int i = 0; str[i] != '\0'; i++) {
printf("%c", toupper(str[i]));
}
printf("\n");
}
実行結果
HELLO
Discussion