当前位置:首页 > 通信资讯 > 正文

C语言isupper()函数:判断字符是否为大写英文字母
头文件:

?
1 #include <ctype.h>

定义函数:

?
1 int isupper(int c);

函数说明:检查参数c是否为大写英文字母。

返回值:若参数c 为大写英文字母,则返回非 0,否则返回 0。

附加说明:此为宏定义,非真正函数。

范例:找出字符串str 中为大写英文字母的字符。

?
1 2 3 4 5 6 7 8 #include <ctype.h> main(){ char str[] = "123c@#FDsP[e?"; int i; for(i = 0; str[i] != 0; i++) if(isupper(str[i])) printf("%c is an uppercase character\n", str[i]); }

执行结果:

?
1 2 3 F is an uppercase character D is an uppercase character P is an uppercase character

C语言islower()函数:判断字符是否为小写字母
头文件:

?
1 #include <ctype.h>

islower() 用来判断一个字符是否是小写字母,其原型为:

?
1 int islower(int c);

【参数】c 为需要检测的字符。

【返回值】若参数c 为小写英文字母,则返回非 0 值,否则返回 0。

注意,此为宏定义,非真正函数。

【实例】判断str 字符串中哪些为小写字母。

?
1 2 3 4 5 6 7 8 #include <ctype.h> main(){ char str[] = "123@#FDsP[e?"; int i; for(i = 0; str[i] != 0; i++) if(islower(str[i])) printf("%c is a lower-case character\n", str[i]); }

输出结果:

?
1 2 3 c is a lower-case character s is a lower-case character e is a lower-case character
如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)

为您推荐:

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。