1、isalpha()
(1)函数原型(我猜的):
int isalpha_(char ch)
{
int ret=0;
if(ch>='A'&&ch<='Z'){
ret=1;
}else if(ch>='a'&&ch<='z'){
ret=2;
}
return ret;
}
(2)函数功能:检查ch是否是字母;
(3)样例;
#include<stdio.h>
int isalpha_(char ch)
{
int ret=0;
if(ch>='A'&&ch<='Z'){
ret=1;
}else if(ch>='a'&&ch<='z'){
ret=2;
}
return ret;
}
int main(void)
{
char ch='a';
char ch1='1';
if(isalpha_(ch)){
printf("%c是字母\n",ch);
}else{
printf("%c不是字母\n",ch);
}
if(isalpha_(ch1)){
printf("%c是字母",ch1);
}else{
printf("%c不是字母",ch1);
}
return 0;
}
输出:
a是字母
1不是字母
--------------------------------
Process exited after 0.03926 seconds with return value 0
请按任意键继续. . .
2、iscntrl()
(1)函数原型(我猜的):
int iscntrl_(char ch)
{
int ret=0;
if(ch>=0&&ch<32||ch==127){
ret=1;
}
return ret;
}
(2)函数功能:检查ch是否为控制字符;
(3)样例:无
3、isdigit()
(1)函数原型(我猜的):
int isdigit_(char ch)
{
int ret=0;
if(ch>='0'&&ch<='9'){
ret=1;
}
return ret;
}
(2)函数功能:检查ch是否是属于0-9的数字
(3)样例:
#include<stdio.h>
int isdigit_(char ch)
{
int ret=0;
if(ch>='0'&&ch<='9'){
ret=1;
}
return ret;
}
int main(void)
{
char ch='2';
char ch1='a';
if(isdigit_(ch)){
printf("%c是数字\n",ch);
}else{
printf("%c不是数字\n",ch);
}
if(isdigit_(ch1)){
printf("%c是数字",ch1);
}else{
printf("%c不是数字",ch1);
}
return 0;
}
输出:
2是数字
a不是数字
--------------------------------
Process exited after 0.08142 seconds with return value 0
请按任意键继续. . .
4、isgraph()
(1)函数原型(我猜的):
int isgraph_(char ch)
{
int ret=0;
if(ch>' '&&ch<='~'){
ret=1;
}
return ret;
}
(2)函数功能:检查ch是否为可显示字符(不包括空格键);
(3)样例:
#include<stdio.h>
int isgraph_(char ch)
{
int ret=0;
if(ch>' '&&ch<='~'){
ret=1;
}
return ret;
}
int main(void)
{
char ch=' ';
char ch1='a';
if(isgraph_(ch)){
printf("%c是可打印字符\n",ch);
}else{
printf("%c不是可打印字符\n",ch);
}
if(isgraph_(ch1)){
printf("%c是可打印字符",ch1);
}else{
printf("%c不是可打印字符",ch1);
}
return 0;
}
输出:
不是可打印字符
a是可打印字符
--------------------------------
Process exited after 0.08828 seconds with return value 0
请按任意键继续. . .
5、islower()
(1)函数原型(我猜的):
int islower_(char ch)
{
int ret=0;
if(ch>='a'&&ch<='z'){
ret=1;
}
return ret;
}
(2)函数功能:检查ch是否为小写字母;
(3)样例:
#include<stdio.h>
int islower_(char ch)
{
int ret=0;
if(ch>='a'&&ch<='z'){
ret=1;
}
return ret;
}
int main(void)
{
char ch='A';
char ch1='a';
if(islower_(ch)){
printf("%c是小写字母\n",ch);
}else{
printf("%c不是小写字母\n",ch);
}
if(islower_(ch1)){
printf("%c是小写字母",ch1);
}else{
printf("%c不是小写字母",ch1);
}
return 0;
}
输出:
A不是小写字母
a是小写字母
--------------------------------
Process exited after 0.08176 seconds with return value 0
请按任意键继续. . .
6、isupper()
(1)函数原型(我猜的):
int islower_(char ch)
{
int ret=0;
if(ch>='A'&&ch<='Z'){
ret=1;
}
return ret;
}
(2)函数功能:检查ch是否为大写字母;
(3)样例:
#include<stdio.h>
int islower_(char ch)
{
int ret=0;
if(ch>='A'&&ch<='Z'){
ret=1;
}
return ret;
}
int main(void)
{
char ch='A';
char ch1='a';
if(islower_(ch)){
printf("%c是大写字母\n",ch);
}else{
printf("%c不是大写字母\n",ch);
}
if(islower_(ch1)){
printf("%c是大写字母",ch1);
}else{
printf("%c不是大写字母",ch1);
}
return 0;
}
输出:
A是大写字母
a不是大写字母
--------------------------------
Process exited after 0.0769 seconds with return value 0
请按任意键继续. . .
7、tolower()
(1)函数原型(我猜的):
char tolower_(char ch)
{
char ret=0;
if(ch>='A'&&ch<='Z'){
ret=ch+32;
}else{
ret=ch;
}
return ret;
}
(2)函数功能:把大写字母转换为小写字母,否则返回本来的字符;
(3)样例:
#include<stdio.h>
char tolower_(char ch)
{
char ret=0;
if(ch>='A'&&ch<='Z'){
ret=ch+32;
}else{
ret=ch;
}
return ret;
}
int main(void)
{
char ch='A';
char ch1='6';
char ch2='a';
putchar(tolower_(ch));
printf("\n");
putchar(tolower_(ch1));
printf("\n");
putchar(tolower_(ch2));
return 0;
}
输出:
a
6
a
--------------------------------
Process exited after 0.08938 seconds with return value 0
请按任意键继续. . .
8、toupper()
(1)函数原型(我猜的):
char tolower_(char ch)
{
char ret=0;
if(ch>='a'&&ch<='z'){
ret=ch-32;
}else{
ret=ch;
}
return ret;
}
(2)函数功能:把小写字母转换为大写字母,否则返回本来的字符;
(3)样例:
#include<stdio.h>
char tolower_(char ch)
{
char ret=0;
if(ch>='a'&&ch<='z'){
ret=ch-32;
}else{
ret=ch;
}
return ret;
}
int main(void)
{
char ch='A';
char ch1='6';
char ch2='a';
putchar(tolower_(ch));
printf("\n");
putchar(tolower_(ch1));
printf("\n");
putchar(tolower_(ch2));
return 0;
}
输出:
A
6
A
--------------------------------
Process exited after 0.08062 seconds with return value 0
请按任意键继续. . .
9、isalnum()
(1)函数原型(我猜的):
int isalnum_(char ch)
{
int ret=0;
if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z'||ch>='0'&&ch<='9'){
ret=1;
}
return ret;
}
(2)函数功能:检查字符是否为数字或字母;
(3)样例:
#include<stdio.h>
int isalnum_(char ch)
{
int ret=0;
if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z'||ch>='0'&&ch<='9'){
ret=1;
}
return ret;
}
int main(void)
{
char ch='g';
char ch1='%';
if(isalnum_(ch)){
printf("%c是字母或数字\n",ch);
}else{
printf("%c不是字母或数字\n",ch);
}
if(isalnum_(ch1)){
printf("%c是字母或数字",ch1);
}else{
printf("%c不是字母或数字",ch1);
}
return 0;
}
输出:
g是字母或数字
%不是字母或数字
--------------------------------
Process exited after 0.08536 seconds with return value 0
请按任意键继续. . .
10、isblank()
(1)函数原型(我猜的):
int isblank_(char ch)
{
int ret=0;
if(ch==' '||ch==' '){
ret=1;
}
return ret;
}
(2)函数功能:检查字符是否为空白字符(' '||'tab');
(3)样例:
#include<stdio.h>
int isblank_(char ch)
{
int ret=0;
if(ch==' '||ch==' '){
ret=1;
}
return ret;
}
int main(void)
{
char ch='g';
char ch1=' ';
if(isblank_(ch)){
printf("%c是空白字符\n",ch);
}else{
printf("%c不是空白字符\n",ch);
}
if(isblank_(ch1)){
printf("%c是空白字符",ch1);
}else{
printf("%c不是空白字符",ch1);
}
return 0;
}
输出:
g不是空白字符
是空白字符
--------------------------------
Process exited after 0.03764 seconds with return value 0
请按任意键继续. . .
11、isspace()
(1)函数原型(我猜的):
int isspace_(char ch)
{
int ret=0;
if(ch==' '||ch=='\t'||ch=='\r'||ch=='\n'||ch=='\a'||ch=='\f'){
ret=1;
}
return ret;
}
(2)函数功能:检查ch是否为空格字符(' '||'\t'||'\r'||'\n'||'\v'||'\f');
(3)样例:
#include<stdio.h>
int isspace_(char ch)
{
int ret=0;
if(ch==' '||ch=='\t'||ch=='\r'||ch=='\n'||ch=='\a'||ch=='\f'){
ret=1;
}
return ret;
}
int main(void)
{
char ch='g';
char ch1=' ';
if(isspace_(ch)){
printf("%c是空格字符\n",ch);
}else{
printf("%c不是空格字符\n",ch);
}
if(isspace_(ch1)){
printf("%c是空格字符",ch1);
}else{
printf("%c不是空格字符",ch1);
}
return 0;
}a
输出:
g不是空格字符
是空格字符
--------------------------------
Process exited after 0.08779 seconds with return value 0
请按任意键继续. . .