- 相干保举
C说话中isalnum()函数和isalpha()函数的对照
C说话isalnum()函数:判定字符是不是为英笔墨母或数字
头文件:
#include
isalnum() 用来判定一个字符是不是为英笔墨母或数字,相称于 isalpha(c) || isdigit(c),其原型为:
int isalnum(int c);
【参数】c 为须要检测的字符。
【前往值】若参数c 为字母或数字,若 c 为 0 ~ 9 a ~ z A ~ Z 则前往非 0,不然前往 0。
注重,isalnum()为宏界说,非真正函数。
【实例】找出str 字符串中为英笔墨母或数字的字符。
#includemain(){ char str[] = "123c@#FDsP[e"; int i; for (i = 0; str[i] != 0; i++) if(isalnum(str[i])) printf("%c is an alphanumeric charactern", str[i]);}
输入成果:
1 is an apphabetic character2 is an apphabetic character3 is an apphabetic characterc is an apphabetic characterF is an apphabetic characterD is an apphabetic characters is an apphabetic characterP is an apphabetic charactere is an apphabetic character
C说话isalpha()函数:判定字符是不是为英笔墨母
头文件:
#include
isalpha() 用来判定一个字符是不是是英笔墨母,相称于 isupper(c)||islower(c),其原型为:
int isalpha(int c);
【参数】c 为须要被检测的字符。
【前往值】若参数c 为英笔墨母(a ~ z A ~ Z),则前往非 0 值,不然前往 0。
注重,isalpha() 为宏界说,非真正函数。
【实例】找出str 字符串中为英笔墨母的字符。
#includemain(){ char str[] = "123c@#FDsP[e"; int i; for (i = 0; str[i] != 0; i++) if(isalpha(str[i])) printf("%c is an alphanumeric charactern", str[i]);}
履行成果:
c is an apphabetic characterF is an apphabetic characterD is an apphabetic characters is an apphabetic characterP is an apphabetic charactere is an apphabetic character
【C说话中isalnum()函数和isalpha()函数的对照】相干文章:
c说话中time函数的用法03-20
C说话中strpbr()函数的用法03-19
C说话中函数的辨别有哪些04-27
C说话中friend友元函数具体剖析04-01
C说话函数的递归和挪用11-28
C说话中前往字符串函数的完成体例03-19
C++挪用C函数的体例11-15
C说话函数的参数和前往值11-16
C说话中对于时候的函数11-24