Chinaunix首页 | 论坛 | 博客
  • 博客访问: 100843
  • 博文数量: 19
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 220
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-20 09:35
文章分类
文章存档

2010年(3)

2009年(16)

我的朋友

分类: LINUX

2009-03-09 21:54:49

#include
#include
void main()
{
 char str[]="?";
 int i;
 for(i=0;str[i]!=NULL;i++)
  if(isalnum(str[i]))
     printf("%c is an alphanumberic character\n",str[i]);
}
 
1 is an alphanumberic character
2 is an alphanumberic character
3 is an alphanumberic character
c is an alphanumberic character
F is an alphanumberic character
D is an alphanumberic character
s is an alphanumberic character
P is an alphanumberic character
e is an alphanumberic character
 
#include
#include
void main()
{
 char str[]="?";
 int i;
 for(i=0;str[i]!=NULL;i++)
  if(isalpha(str[i]))
     printf("%c is an alphanumberic character\n",str[i]);
}
 
c is an alphanumberic character
F is an alphanumberic character
D is an alphanumberic character
s is an alphanumberic character
P is an alphanumberic character
e is an alphanumberic character
 
#include
#include
void main()
{
 int i;
 for(i=125;i<130;i++)
  if(isascii(i))
     printf("%d is an ascii character:%c \n",i,i);
  else
     printf("%d is not an ascii character\n",i);
}
 
125 is an ascii character:}
126 is an ascii character:~
127 is an ascii character
128 is not an ascii character
129 is not an ascii character
#include
#include
void main()
{
 char str[]="123c @# FD\tsP[e?\n";
 int i;
 for(i=0;str[i]!=NULL;i++)
  if(isdigit(str[i]))
   printf("%c is an dight character\n",str[i]);
}
 
1 is an dight character
2 is an dight character
3 is an dight character
#include
#include
void main()
{
 char str[]="123c @# FD\tsP[e ?\n";
 int i;
 for(i=0;str[i]!=NULL;i++)
  if(isgraph(str[i]))
   printf("str[%d] is printable character%c\n",i,str[i]);
}
str[0] is printable character1
str[1] is printable character2
str[2] is printable character3
str[3] is printable characterc
str[5] is printable character@
str[6] is printable character#
str[8] is printable characterF
str[9] is printable characterD
str[11] is printable characters
str[12] is printable characterP
str[13] is printable character[
str[14] is printable charactere
str[16] is printable character?
 
#include
#include
void main()
{
 char str[]="123c @# FD\ tsP[e ?\n";
 int i;
 for(i=0;str[i]!=NULL;i++)
  if(islower(str[i]))
   printf("%c is a lower-case character%d\n",str[i]);
}
c is a lower-case character-1073747752
t is a lower-case character-1073747752
s is a lower-case character-1073747752
e is a lower-case character-1073747752
#include
#include
void main()
{
 char str[]="123c @# FD\ tsP[e ?\n";
 int i;
 for(i=0;str[i]!=NULL;i++)
  if(isprint(str[i]))
   printf("str[%d] is printable character:%c\n",i,str[i]);
}
str[0] is printable character:1
str[1] is printable character:2
str[2] is printable character:3
str[3] is printable character:c
str[4] is printable character:
str[5] is printable character:@
str[6] is printable character:#
str[7] is printable character:
str[8] is printable character:F
str[9] is printable character:D
str[10] is printable character:
str[11] is printable character:t
str[12] is printable character:s
str[13] is printable character:P
str[14] is printable character:[
str[15] is printable character:e
str[17] is printable character:?

#include
#include
void main()
{
 char str[]="123c @# FD\tsP[e ?\n";
 int i;
 for(i=0;str[i]!=NULL;i++)
  if(ispunct(str[i]))
   printf("str[%d] is 特殊字符 character:%c\n",i,str[i]);
}
 
str[5] is 特殊字符 character:@
str[6] is 特殊字符 character:#
str[13] is 特殊字符 character:[
str[16] is 特殊字符 character:?
 
#include
#include
void main()
{
 char str[]="123 c @# FD \tsP [e?\n";
 int i;
 for(i=0;str[i]!=NULL;i++)
  if(isspace(str[i]))
   printf("str[%d] is a while-space character:%d\n",i,str[i]);
}
str[3] is a while-space character:9
str[5] is a while-space character:32
str[8] is a while-space character:32
str[11] is a while-space character:32
str[12] is a while-space character:9
str[15] is a while-space character:32
str[19] is a while-space character:10
#include
#include
void main()
{
 char str[]="123c @# FD\tsP[e ?\n";
 int i;
 for(i=0;str[i]!=NULL;i++)
  if(isupper(str[i]))
   printf("str[%d] is 大写字母 character:%c\n",i,str[i]);
}
str[8] is 大写字母 character:F
str[9] is 大写字母 character:D
str[12] is 大写字母 character:P
 
#include
#include
void main()
{
 char str[]="123c @# FD\tsP[e ?\n";
 int i;
 for(i=0;str[i]!=NULL;i++)
  if(isxdigit(str[i]))
   printf("str[%d] is 十六进制 character:%c\n",i,str[i]);
}
str[0] is 十六进制character:1
str[1] is 十六进制 character:2
str[2] is 十六进制 character:3
str[3] is 十六进制character:c
str[8] is 十六进制 character:F
str[9] is 十六进制 character:D
str[14] is 十六进制 character:e

 

 
 
 
 

 
 
 
 
 
 
 
阅读(1485) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~