The Standard C Library for Linux:ctype.h

2016-02-19 12:33 10 1 收藏

今天给大家分享的是由图老师小编精心为您推荐的The Standard C Library for Linux:ctype.h,喜欢的朋友可以分享一下,也算是给小编一份支持,大家都不容易啊!

【 tulaoshi.com - 编程语言 】


  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 script 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

来源:http://www.tulaoshi.com/n/20160219/1601158.html

延伸阅读
    前面提到,Oracle10g重建Procedure的处理有所增强,最初看到这个增强的时候,我想这个增强是否可以减少困扰已久的Library Cache的竞争呢?     我们看一下以下测试,首先在第一个session执行操作: SQL create or replace PROCEDURE pining 2 IS 3 BEGIN 4 NULL; 5 END; 6 / Procedure created. SQL SQL ...
  文/余海发     本文介绍了Linux的C开发环境的构成和安装,使读者对Linux的C开发环境能有初步的了解。 你了解Linux吗?相信现在越来越多的人会说“是”的。那么你了解到何种程度呢?不可否认,目前决大多数的Linux用户对Linux的了解还处于比较低级的层次,他们可能会几条命令、会配几种服务、会用rpm来安装软...
getenv(取得环境变量内容) 相关函数 putenv,setenv,unsetenv表头文件 #include 定义函数 char * getenv(const char *name);函数说明 getenv()用来取得参数name环境变量的内容。参数name为环境变量的名称,如果该变量存在则会返回指向该内容的指针。环境变量的格式为name=value。返回值 执行成功则返回指向该内容的指针,找不到符合的环境...
标签: Web开发
使用库元素必须首先在DW中正确建立站点。 库被设计用来使重复性的工作更快、更容易并尽可能地无差错。 任何网页中的元素,无论文本还是图形均可以指定为库元素。 库元素可以用来放置在同一个站点内的任何页面中,而不需要重新输入文本或插入图片等。 可以在任何时候修改库文件。编辑完成,保存,DW会同时更新所有应用...
DataOleDb Data Provider for Enterprise Library 1.0This is a first attempt at the necessary OleDb classes for Enterprise Library 1.0. It consists of an OleDbDatabase class, an OleDbCommandWrapper class, and numerous test fixtures.Sybase ASE Data ProviderThis Enterprise Library extension uses the Sybase ASE .NET Data Pr...

经验教程

758

收藏

81
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部