The Standard C Library for Linux:ctype.h

2016-02-19 12:33 8 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

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

延伸阅读
标签: Web开发
使用库元素必须首先在DW中正确建立站点。 库被设计用来使重复性的工作更快、更容易并尽可能地无差错。 任何网页中的元素,无论文本还是图形均可以指定为库元素。 库元素可以用来放置在同一个站点内的任何页面中,而不需要重新输入文本或插入图片等。 可以在任何时候修改库文件。编辑完成,保存,DW会同时更新所有...
标签: Web开发
    使用库元素必须首先在DW中正确建立站点。 库被设计用来使重复性的工作更快、更容易并尽可能地无差错。 任何网页中的元素,无论文本还是图形均可以指定为库元素。 库元素可以用来放置在同一个站点内的任何页面中,而不需要重新输入文本或插入图片等。 可以在任何时候修改库文件。编辑完成,保存,DW...
处理 C++ 中的异常会在语言级别上碰到少许隐含限制,但在某些情况下,您可以绕过它们。学习各种利用异常的方法,您就可以生产更可靠的应用程序。保留异常
crypt(将密码或数据编码) 相关函数 getpass表头文件 #define _XOPEN_SOURCE#include 定义函数 char * crypt (const char *key,const char * salt);函数说明 crypt()将使用Data EncryptionStandard(DES)演算法将参数key所指的字符串加以编码,key字符串长度仅取前8个字符,超过此长度的字符没有意义。参数salt为两个字符组成的字符串,由a-z...
    前面提到,Oracle10g重建Procedure的处理有所增强,最初看到这个增强的时候,我想这个增强是否可以减少困扰已久的Library Cache的竞争呢?     我们看一下以下测试,首先在第一个session执行操作: SQL create or replace PROCEDURE pining 2 IS 3 BEGIN 4 NULL; 5 END; 6 / Procedure created. SQL SQL ...

经验教程

653

收藏

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