C++函数isacscii

来源:互联网 发布:ubuntu手机远程控制 编辑:程序博客网 时间:2024/05/22 17:38
功能:
判断输入文字是否为有效的ASCII 字符。
所在函数库:ctype.h
语法:
#include<ctype.h>
int isascii(int c)
函数返回值:当c的低位字节在0~127范围内(0x00~0x7f),返回非零值.
#include<iostream.h>
#include<ctype.h>
int main()
{
char c1='@';
char c2='a';
if (isalpha (c1)!=0 )
  cout<<c1<<" is the ASCII character!"<<endl;  //当c1为有效的ASCII字符时,打印信息
else
  cout<<c1<<" is not the ASCII character!"<<endl; //当c1为非有效的ASCII字符时,打印信息
    if (isalpha (c2)!=0 )
  cout<<c2<<" is the ASCII character!"<<endl;  //当c1为有效的ASCII字符时,打印信息
else
  cout<<c2<<" is not the ASCII character!"<<endl; //当c1为非有效的ASCII字符时,打印信息
return 0;
}
运行结果:
@ is the ASCII character!
A  is the ASCII character! 

原创粉丝点击