当前位置: 代码迷 >> 综合 >> C/C++ isalpha、isalnum、islower、isupper函数详解
  详细解决方案

C/C++ isalpha、isalnum、islower、isupper函数详解

热度:35   发布时间:2023-12-16 00:45:43.0

isalpha函数

isalpha()函数用来判断一个字符是否为字母,如果是字母则返回非零,否则返回零。

cout << isalpha('d') << endl;
cout << isalpha('4') << endl; --------结果如下--------
1
0

isalnum函数

isalnum()函数用来判断一个字符是否为数字或字母,是则输出非零,否则输出零。

cout << isalnum('d') << endl;
cout << isalnum('4') << endl;
cout << isalnum('.') << endl;-----------结果如下--------------
1
1
0

islower函数

islower()函数用来判断一个字符是否为小写字母。

cout << islower('d') << endl;
cout << islower('4') << endl;
cout << islower('A') << endl;------------结果如下----------
1
0
0

isupper函数

ispuuer()函数用来判断一个字符是否为大写字母。

cout << isupper('a') << endl;
cout << isupper('2') << endl;
cout << isupper('A') << endl;------------结果如下-----------
0
0
1