论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > C语言程序设计教程
Tag:新手,函数,指针,数据类型,对象,Turbo,入门,运算符,数组,结构,二级,,tc,游戏,试题,问答,编译,视频教程

The Standard C Library for Linux:ctype.h

文章类别:C语言程序设计 | 发表日期:2008-9-24 14:38:11

Part Four: <ctype.h> Character Handling
By James M. Rogers

--------------------------------------------------------------------------------

The last article was on <stdio.h> Input and Output. This article is on <ctype.h> character handling.

Character handling allows us to clasify characters as alpha, digit, hexdigit, whitespace, printable, lowercase, uppercase, punctuation and to map to and from the upper and lowercase alphabets. Most importantly <ctype.h> implements these functions in a non-system dependent way.

If you write your program assuming that every computer is an ASCII computer you will have trouble porting your program to non ASCII machines. If you write your character handling functions in terms of these functions your program will be much more portable to other platforms.

I am assuming a knowledge of c programming on the part of the reader. There is no guarantee of accuracy in any of this information nor suitability for any purpose.

The program example that I will do this month will go thru the entire 8bit ASCII range and tell us to which classes any one chacter belongs. The example is rogers_example04.c. The output the program generates will be an html document and the run from my system is rogers_example04.html .
This program can be used as a cgi-bin s cript and is a demonstration of the flexibility of the c language.


As always, if you see an error in my documentation please tell me and I will correct myself in a later document. See corrections at end of the document to review corrections to the previous articles.

Character Handling


#include <ctype.h>

int isalpha(int c);
int isalnum(int c);
int isdigit(int c);
int isxdigit(int c);

int iscntrl(int c);
int isspace(int c);

int ispunct(int c);
int isgraph(int c);
int isprint(int c);

int islower(int c);
int isupper(int c);

int tolower(int c);
int toupper(int c);

isalpha returns true if the character is in the range of A-Z or a-z.
isalnum returns true if the character is in the range of A-Z or a-z or 0-9.

isdigit returns true if the character is in the range of 0-9.

isxdigit returns true if the character is in the range of 0-9 or a-f or A-F.

iscntrl returns true if the character is in the set (FF, NL, CR, HT, VT, BEL or BS).

isspace returns true if the character is in the set (space, FF, NL, CR, HT or VT).

ispunct returns true if the character is a nonalnum, nonspace and noncntrl.

isgraph returns true if the character isalnum or ispunct.

isprint returns true if the character isspace or isgraph.

islower returns true if the character is in the range of a-z.

isupper returns true if the character is in the range of A-Z.

tolower if isupper return the lowercase character otherwise return the character.

toupper if islower return the uppercase character otherwise return the character.

From:www.linuxgazette.com
视频教程列表
文章教程搜索
 
C语言程序设计推荐教程
C语言程序设计热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058