{
intc,j,i;
for(i=0,j=strlen(s)-1;i<j;i,j--) //完成倒置功能,不包括字符串结束符'/0'
{
c=s[i];
s[i]=s[j];
s[j]=c;
}
}
int main() //主函数,用于测试reverse函数的功能
{
chars[]="123456";
reverse(s); //调用倒置函数
printf("%s\n",s); //输出倒置后的字符串
return 0;
}
输出结果:654321
int isdigit(int ch);
检查ch是否是数字(0-9)
是返回1,否则返回0
#include <stdio.h>
#include <ctype.h>
int main()
{
char ch1='1';
char ch2='a';
if(isdigit(ch1)!=0)
printf("%c is the ASCII number\n",ch1);
else
printf("%c is not the ASCII number\n",ch1);
if(isdigit(ch2)!=0)
printf("%c is the ASCIInumber\n",ch2);
else
printf("%c is not the ASCII number\n",ch2);
return 0;
}
输出结果:
1 is the ASCII number
a is not the ASCII number
intisalpha(intch);
检查ch是否是字母
是返回1,否则返回0
#include<stdio.h>
#include<ctype.h>
int main()
{
char ch1='*';
char ch2='a';
if(isalnum(ch1)!=0)
printf("%c is the ASCII number or alphebet\n",ch1);
else
printf("%c is not the ASCII number nor alphebet\n",ch1);
if(isalnum(ch2)!=0)
printf("%c is the ASCII number or alphebet\n",ch2);
else
printf("%c is not the ASCII number nor alphebet\n",ch2);
return 0;
}
输出结果:
* is not the ASCII number nor alphabet
a is the ASCII number or alphabet
intislower(intch);
检查ch是否小写字母(a-z)
是返回1,否则返回0
extern int isupper(int c);
判断字符c是否为大写英文字母
#include <ctype.h>
#include <stdio.h>
int main()
{
char Test[]="a1B2c3D4";
char *pos;
pos=Test;
while(*pos!=0)
{
if(isupper(*pos))
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-34960-12.html
那就是雄赳赳气昂昂