大宇私人领地伊甸园丨宁愿做了后悔,也不要错过后悔[www.mrdayu.com]
注册

24小时联系邮箱:[email protected]

所有文章
大宇私人伊甸园: 首页 > 所有文章 > 编程人生 > C/C++语言 > C标准库详解 > isascii函数详解


友情链接:


isascii函数详解

发布时间:2018/11/29 C标准库详解 标签isascii阅读:33

函数原型:

extern int isascii(int c);

头文件:

#include <ctype.h>

功能:

判断字符c是否为ascii码

说明:

当c为ascii码时,返回非零值,否则返回零。ascii码指0x00-0x7F之间的字符

Linux平台测试:

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

int main(){
        int a=0x20;
        printf("a isascii = %s\n",isascii(a)?"Yess":"No");
        a=20;
        printf("a isascii = %s\n",isascii(a)?"Yess":"No");
        a='a';
        printf("a isascii = %s\n",isascii(a)?"Yess":"No");
        a=0x80;
        printf("a isascii = %s\n",isascii(a)?"Yess":"No");
        return 0;
}

运行测试:

[[email protected] STDC]$ gcc stdc_isascii.c
[[email protected] STDC]$ ./a.out 
a isascii = Yess
a isascii = Yess
a isascii = Yess
a isascii = No

Widnows平台测试:

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

int main(){
	int a = 0x20;
	printf("a isascii = %s\n", isascii(a) ? "Yess" : "No");
	a = 20;
	printf("a isascii = %s\n", isascii(a) ? "Yess" : "No");
	a = 'a';
	printf("a isascii = %s\n", isascii(a) ? "Yess" : "No");
	a = 0x80;
	printf("a isascii = %s\n", isascii(a) ? "Yess" : "No");
	getchar();
	return 0;
}

运行结果:

a isascii = Yess
a isascii = Yess
a isascii = Yess
a isascii = No
The bottom line, for me, is simple.

Let’s hope it doesn’t take 500 years for a discipline of testing to becomes the standard for software developers.

From:dayu

您好!请登录

合作网站快捷登录:
点击取消回复

已有0评论

    大宇博客

    点击这里给我发消息 点击这里给我发消息 点击这里给我发消息 点击这里给我发消息