void mainisalpha 怎么去编写不用ctype.h

|— C/C++(78)
int isalpha(int ch)& 若ch是字母('A'-'Z','a'-'z')返回非0值,否则返回0
int isalnum(int ch)& 若ch是字母('A'-'Z','a'-'z')或数字('0'-'9')
&&&&&&&&&&&&&&&&&&&& 返回非0值,否则返回0
int isascii(int ch)& 若ch是字符(ASCII码中的0-127)返回非0值,否则返回0
int iscntrl(int ch)& 若ch是作废字符(0x7F)或普通控制字符(0x00-0x1F)
&&&&&&&&&&&&&&&&&&&& 返回非0值,否则返回0
int isdigit(int ch)& 若ch是数字('0'-'9')返回非0值,否则返回0
int isgraph(int ch)& 若ch是可打印字符(不含空格)(0x21-0x7E)返回非0值,否则返回0
int islower(int ch)& 若ch是小写字母('a'-'z')返回非0值,否则返回0
int isprint(int ch)& 若ch是可打印字符(含空格)(0x20-0x7E)返回非0值,否则返回0
int ispunct(int ch)& 若ch是标点字符(0x00-0x1F)返回非0值,否则返回0
int isspace(int ch)& 若ch是空格(' '),水平制表符(' '),回车符(' '),
&&&&&&&&&&&&&&&&&&&& 走纸换行('f'),垂直制表符('v'),换行符(' ')
&&&&&&&&&&&&&&&&&&&& 返回非0值,否则返回0
int isupper(int ch)& 若ch是大写字母('A'-'Z')返回非0值,否则返回0
int isxdigit(int ch) 若ch是16进制数('0'-'9','A'-'F','a'-'f')返回非0值,
&&&&&&&&&&&&&&&&&&&& 否则返回0
int tolower(int ch)& 若ch是大写字母('A'-'Z')返回相应的小写字母('a'-'z')
int toupper(int ch)& 若ch是小写字母('a'-'z')返回相应的大写字母('A'-'Z')
ctype.h的C标准库的头文件中提供的声明几个有用的函数测试和字符映射。
所有的功能都接受int作为参数,其值必须是EOF或为unsigned char表示。
所有函数返回的参数c非零(true),如果满足条件。否则返回0。
以下是在头文件ctype.h中定义的函数:
函数及说明
int isalnum(int c)
该函数检查传递的字符是否是字母数字。
int isalpha(int c)
该函数是否传递的字符是字母。
int iscntrl(int c)
该函数是否传递的字符是控制字符。
int isdigit(int c)
该函数是否传递的字符是十进制数字。
int isgraph(int c)
该函数是否传递的字符的图形表示,使用的语言环境。
int islower(int c)
该函数检查传递的字符是否是小写字母。
int isprint(int c)
该函数检查传递的字符是否是可打印的。
int ispunct(int c)
该函数检查传递的字符是否是标点符号。
int isspace(int c)
该函数检查传递的字符是否是空白。
int isupper(int c)
该函数检查传递的字符是否是大写字母。
int isxdigit(int c)
该函数检查传递的字符是否是十六进制数字。
该库还包含两个转换函数,也接受并返回一个“整数”
函数及说明
int tolower(int c)
这个函数转换大写字母为小写。
int toupper(int c)
这个函数小写字母转换为大写。
字符类说明
A set of whole numbers { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
Hexadecimal digits
This is the set of { 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f }
Lowercase letters
This is a set of { a b c d e f g h i j k l m n o p q r s t u v w x y z }
Uppercase letters
A set of whole numbers {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }
This is a set of lowercase letters and uppercase letters
Alphanumeric characters
This is a set of Digits, Lowercase letters and Uppercase letters
Punctuation characters
This is a set of ! & # $ % & ' ( ) * + , - . / : ; & = & ? @ [ ] ^ _ ` { | } ~
Graphical characters
This is a set of Alphanumeric characters and Punctuation characters.
Space characters
This is a set of tab, newline, vertical tab, form feed, carriage return, and space.
Printable characters
This is a set of Alphanumeric characters, Punctuation characters and Space characters.
Control characters
In ASCII, these characters have octal codes 000 through 037, and 177 (DEL).
Blank characters
These are space and tab.
Alphabetic characters
This is a set of Lowercase letters and Uppercase letters.
C++ 语言下
头文件:#include &cctype&
说明: 字符处理库
功能一:字符测试
1& 函数原型均为int isxxxx(int)
2& 参数为int, 任何实参均被提升成整型
3& 只能正确处理处于[0, 127]之间的值
功能二:字符映射
1& 函数原型为int toxxxx(int)
2& 对参数进行检测, 若符合范围则转换, 否则不变
备注说明:C语言下的此类功能头文件是&ctype.h&
以下是&cctype&头文件的声明:
// cctype standard header
#pragma once
#ifndef _CCTYPE_
#define _CCTYPE_
#include &yvals.h&
#ifdef _STD_USING
#undef _STD_USING
#include &ctype.h&
#define _STD_USING
#else /* _STD_USING */
#include &ctype.h&
#endif /* _STD_USING */
#ifndef RC_INVOKED
#if _GLOBAL_USING
_STD_BEGIN
using :: using :: using ::
using :: using :: using ::
using :: using :: using ::
using :: using :: using ::
#endif /* _GLOBAL_USING */
#endif /* RC_INVOKED */
/* remove any (improper) macro overrides */
#undef isalnum
#undef isalpha
#undef isblank
#undef iscntrl
#undef isdigit
#undef isgraph
#undef islower
#undef isprint
#undef ispunct
#undef isspace
#undef isupper
#undef isxdigit
#undef tolower
#undef toupper
#endif /* _CCTYPE_ */
* Copyright (c)
by P.J. Plauger.
ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V5.02:0009 */
ASCII码字符检测结果表下图为ASCII字符检测结果表格,画X的表示“是”(即真,返回值非0)
ASCII values
characters
0x00 .. 0x08
NUL, (other control codes)
tab ('\t')
0x0A .. 0x0D
(white-space control codes:'\f','\v','\n','\r')
0x0E .. 0x1F
(other control codes)
space (' ')
0x21 .. 0x2F
!&#$%&'()*+,-./
0x30 .. 0x39
0x3a .. 0x40
0x41 .. 0x46
0x47 .. 0x5A
GHIJKLMNOPQRSTUVWXYZ
0x5B .. 0x60
0x61 .. 0x66
0x67 .. 0x7A
ghijklmnopqrstuvwxyz
0x7B .. 0x7E
C++ reference上的:
&cctype& (ctype.h)
Character handling functions
This header declares a set of functions to classify and transform individual characters.
These functions take the&int&equivalent of one character as parameter and return an&int&that can either be another character or a value representing a boolean value: an&int&value of&0&means false, and an&int&value
different from&0represents true.
There are two sets of functions:
Character classification functions
They check whether the character passed as parameter belongs to a certain category:
Check if character is alphanumeric&(function )
Check if character is alphabetic&(function )
Check if character is blank&(function )
Check if character is a control character&(function )
Check if character is decimal digit&(function )
Check if character has graphical representation&(function )
Check if character is lowercase letter&(function )
Check if character is printable&(function )
Check if character is a punctuation character&(function )
Check if character is a white-space&(function )
Check if character is uppercase letter&(function )
Check if character is hexadecimal digit&(function )
Character conversion functions
Two functions that convert between letter cases:
Convert uppercase letter to lowercase&(function )
Convert lowercase letter to uppercase&(function )
For the first set, here is a map of how the original 127-character ASCII set is considered by each function (an x indicates that the function returns true on that character)
ASCII values
characters
0x00 .. 0x08
NUL, (other control codes)
tab ('\t')
0x0A .. 0x0D
(white-space control codes:'\f','\v','\n','\r')
0x0E .. 0x1F
(other control codes)
space (' ')
0x21 .. 0x2F
!&#$%&'()*+,-./
0x30 .. 0x39
0x3a .. 0x40
0x41 .. 0x46
0x47 .. 0x5A
GHIJKLMNOPQRSTUVWXYZ
0x5B .. 0x60
0x61 .. 0x66
0x67 .. 0x7A
ghijklmnopqrstuvwxyz
0x7B .. 0x7E
The characters in the extended character set (above 0x7F) may belong to diverse categories depending on the locale and the platform. As a general rule,&,&&and&&return
true on these for the standard C locale on most platforms supporting extended character sets.
几个程序实例:
/*转自http://blog.csdn.net/lion_hbeu/article/details/*/
#include &iostream&
#include &cctype&
#include &cstdio&
void printHead();
int main()
char str_ch[50];
char str_ch1[50];
cout&&&input your choice,(0:大小写转换测试,1:打印ASCII字符检测结果表)\n&;
if(choice == 0)
cout&&&input a string\n&;
cout&&&源字符串:&&&str_ch&&
int len = sizeof(str_ch);
for(int i =0;i&i++)
str_ch1[i] = tolower(str_ch[i]);
cout&&&小写字符串:&&&str_ch1&&
for(int i =0;i&i++)
str_ch1[i] =toupper(str_ch[i]);
cout&&&大写字符串:&&&str_ch1&&
else if(choice == 1)
printHead();
for(int i=0;i&=127;i++)
printf(&0x%02x%6d&,i,i);
if(i&=8&&i&=13 || i==127 )
printf(&%10s&,&&);
printf(&%10c&,i);
(isalnum(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(isalpha(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(isblank(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(iscntrl(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(isdigit(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(isgraph(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(islower(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(isprint(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(ispunct(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(isspace(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(isupper(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
(isxdigit(i)!=0)?printf(&%10s&,&Y&):printf(&%10s&,&N&);
printf(&\n&);
void printHead()
printf(&%10s&,&value&);
printf(&%10s&,&chara&);
printf(&%10s&,&isalnum&);
printf(&%10s&,&isalpha&);
printf(&%10s&,&isblank&);
printf(&%10s&,&iscntrl&);
printf(&%10s&,&isdigit&);
printf(&%10s&,&isgraph&);
printf(&%10s&,&islower&);
printf(&%10s&,&isprint&);
printf(&%10s&,&ispunct&);
printf(&%10s&,&isspace&);
printf(&%10s&,&isupper&);
printf(&%10s&,&isxdigit&);
printf(&\n&);
/*转自http://blog.csdn.net/gyysmall/article/details/*/
//用循环判断ASCII从0~127之间的字符类型
cctype中的常用函数
如果参数是字母数字,即字母或者数字,函数返回true
如果参数是字母,函数返回true
如果参数是控制字符,函数返回true
如果参数是数字(0-9),函数返回true
如果参数是除空格之外的打印字符,函数返回true
如果参数是小写字母,函数返回true
如果参数是打印字符(包括空格),函数返回true
如果参数是标点符号,函数返回true
如果参数是标准空白字符,如空格、换行符、水平或垂直制表符,函数返回true
如果参数是大写字母,函数返回true
isxdigit() 如果参数是十六进制数字,即0-9、a-f、A-F,函数返回true
如果参数是大写字符,返回其小写,否则返回该参数
如果参数是小写字符,返回其大写,否则返回该参数
#include &iostream&
#include &cctype&
int main()
unsigned char c='\0';
for(;(int)c&=127;c++)
cout&&&ASCII为 &&&(int)c&&& 的字符为 &;
if(iscntrl(c))//判断是否为控制字符
{ cout&&(iscntrl(c)?&控制字符
cout&&(isspace(c)?&标准空白字符,如空格、换行符、水平或垂直制表符&:&&);
//非控制字符
cout&&c&&& &;
cout&&(isprint(c)?&打印字符(包括空格)
cout&&(isgraph(c)?&除空格之外的打印字符
cout&&(isalnum(c)?&字母数字
cout&&(isalpha(c)?&字母
cout&&(islower(c)?&小写字母
cout&&(isupper(c)?&大写字母
cout&&(isdigit(c)?&数字(0-9)
cout&&(isxdigit(c)?&十六进制数字(0-9,A-F,a-f)
cout&&(ispunct(c)?&标点符号
//cout&&&=============================================&&&
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:133406次
积分:3060
积分:3060
排名:第12032名
原创:126篇
转载:111篇
译文:13篇
评论:28条
(window.slotbydup = window.slotbydup || []).push({
id: '4740881',
container: s,
size: '200,200',
display: 'inlay-fix'姹傚ぇ瀹跺府涓嬪繖~~鐪嬬湅杩欓亾棰樻

我要回帖

更多关于 int main void 的文章

 

随机推荐