您的位置:首页 > 其它

isalnum

2020-02-02 17:20 369 查看

isalnum

测试字符是否为英文(alpha character)或数字(numeric character)

相关函数

isalpha,isdigit,islower,isupper

表头文件

[code]#include <ctype.h>

定义函数

[code]int isalnum(int c)

函数说明

检查参数c是否为英文字母或阿拉伯数字,在标准c中相当于使用“isalpha(c) || isdigit(c)”做测试。

返回值

若参数c为字母或数字,则返回TRUE,否则返回NULL(0)。

附加说明

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

范例

[code]/* 找出str 字符串中为英文字母或数字的字符*/

#include <ctype.h>
#include <stdio.h>

int main()
{
char str[] = "123c@#FDsP[e?";
for(int i = 0; str[i] != 0; i++)
if(isalnum(str[i]))
printf("%c is an alphanumeric character\n",str[i]);
return 0;

}

执行

[code]1 is an alphanumeric character
2 is an alphanumeric character
3 is an alphanumeric character
c is an alphanumeric character
F is an alphanumeric character
D is an alphanumeric character
s is an alphanumeric character
P is an alphanumeric character
e is an alphanumeric character
  • 点赞
  • 收藏
  • 分享
  • 文章举报
IotJuZiPi 发布了18 篇原创文章 · 获赞 0 · 访问量 1229 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: