Cstandardlibrary(c标准库)

上传人:缘*** 文档编号:333288764 上传时间:2022-09-01 格式:PDF 页数:39 大小:3.15MB
返回 下载 相关 举报
Cstandardlibrary(c标准库)_第1页
第1页 / 共39页
Cstandardlibrary(c标准库)_第2页
第2页 / 共39页
Cstandardlibrary(c标准库)_第3页
第3页 / 共39页
Cstandardlibrary(c标准库)_第4页
第4页 / 共39页
Cstandardlibrary(c标准库)_第5页
第5页 / 共39页
点击查看更多>>
资源描述

《Cstandardlibrary(c标准库)》由会员分享,可在线阅读,更多相关《Cstandardlibrary(c标准库)(39页珍藏版)》请在金锄头文库上搜索。

1、C s t a n d a r d l i b r a r y (c 标准库):diagnosis defines only a macro assert with a reference,whichis defined as follows:Void assert(int expression)The assert macro is used to add diagnostic features to a program,which can test a condition and possibly terminate the program.Execute statement:Assert

2、(expression);When the expression is 0,a message is displayed at theterminal:Assertion failed:0,file source file name,line line numberAbnormal program terminationThen invoke the abort to terminate the execution of the program.In,the macro assert is defined as conditionalcompilation,and if the macro N

3、DEBUG is defined in the sourcefile,the assert macro will be ignored even if the header file is included:character class testingF unctions that define test characters are defined in headerfile.In these functions,the arguments for eachfunction are integer int,and each parameter is either EOF orchar ty

4、pe.The list of standard functions defined in is as follows:Functions defined in Function definitionFunction brief introductionInt isalnum(int c)Check whether the characters are letters or numbersInt isalpha(int c)Check if the characters are lettersInt isascii(int c)Check if the character is ASCIIInt

5、 iscntrl(int c)Check that the character is a control characterInt isDigit(int c)Check that the characters are numeric charactersInt isgraph(int c)Check that the characters are printable charactersInt islower(int c)Check if the characters are lowercase lettersInt isprint(int c)Check that the characte

6、rs are printable charactersInt ispunct(int c)Check if the characters are punctuation charactersInt isspace(int c)Check if the character is a space characterInt isupper(int c)Check if the characters are uppercase lettersInt isxdigit(int c)Check if the character is a sixteen digit numeric characterInt

7、 toupper(int c)Converts lowercase letters to uppercase lettersInt tolower(int c)Converts uppercase letters to lower case lettersThese standard functions defined in,and somecommonly used nonstandard character processing functions,willbe described in detail in the Eleventh chapter.:error handlingTwo c

8、onstants,one variable,are defined in.1,EDOMIt represents the wrong code for mathematical domain errors.2,ERANGEIt represents an error code that results out of bounds.3,errnoThis is a variable that is set to indicate the type of errorin the system call.:integer constantIn header file,some constants t

9、hat representinteger sizes are defined.The following are the expressionsand meanings of these constants,as shown in the followingtable.Character constants defined in character constantsValueMeaningCHAR_BITEightNumber of char typesCHAR_M AX255 or 127Char type maximumCHAR_MIN0 or-127Char type minimumI

10、NT_MIN-32767Int type minimumINT_MAXThirty-two thousand seven hundred and sixty-sevenInt type maximumL0NG_MAXTwo billion one hundred and forty-seven million four hundredand eighty-three thousand six hundred and forty-sevenLong type maximumL0NG_MIN-2147483647Long type minimumSCHAR_MAXOne hundred and t

11、wenty-sevenSigned char type maximumSCHAR_MIN-127S i g n e d c h a r t y p e m i n i m u mS H R T J I AXT h i r t y-t w o t h o u s a n d s e v e n h u n d r e d a n d s i x t y-s e v e nMa x i m u m v a l u e o f t y p e s h o r tS H R T _ MI N-3 2 7 6 7T h e m i n i m u m v a l u e o f t h e s h o

12、r t t y p eU C H AR _ MAXT w o h u n d r e d a n d f i f t y-f i v eu n s i g n e d c h a r 类型最大值u i n t _ m a x六万五千五百三十五u n s i g n e d i n t 类型最大值u l o n g _ m a x四十二亿九千四百九十六万七千二百九十五无符号长类型最大值u s h r t _ m a x六万五千五百三十五无符号短类型的最大值:地域环境现场。在 现场。”中,定义了 7个常量,一个结构,2个函数。1、常量的定义l c _ a l l:传递给s e t l o c a

13、l e 的第一个参数,指定要更改该现场的哪个方面。l c _ c o l l a t e:s t r c o i l 和 s t r x f r m 的行为。l c _ c t y p e:字符处理函数。l c _ m o n e t a r y:l o c a l e c o n v 返回的货币信息。1 c n u m e r i c:l o c a l e c o n v 返回的小数点和货币信息。I c t i m e:s t r f t i m e 的行为。以上扩展成具有唯一取值的整型常数表达式,可作为s e t l o c a l e 的第一个参数。空:由实现环境定义的空指针。2、结

14、构I c o n v结构该结构用于存储和表示当前的设置其结构定义如下现场:结 构I c o n v(c h a r *d e c i m a l _ p o i n t;c h a r *t h o u s a n d s _ s e p;字符分组;c h a r *i n t _ c u r r _ s y m b o l;c h a r *c u r r e n c y _ s y m b o l;c h a r *m o n d e c i m a l p o i n t;c h a r *m o n _ t h o u s a n d s _ s e p;c h a r *m o n

15、g r o u p i n g;c h a r *p o s i t i v e s i g n;c h a r *n e g a t i v e _ s i g n;焦 i n t f r a c d i g i t s;焦 frac_digits;焦 P_cs_precedes;焦 P_sep_by_space;焦 n cs precedes;焦 n_sep_by_space;焦 p_sign_posn;焦 n_sign_posn;;3、函数struct iconv*localeconv(void);函数localeconv将一个iconv类型的对象的数据成员设置成为按照当前地域环境的有关

16、规则进行数量格式化后的相应值结构。char*setlocale(int 类型,char*现场);函数setlocale用于更改和查询程序的整个当前地域环境或部分设置。地域环境变量由参数范畴(上面定义的6个常量)和现场指定。H :数学函数数学。在 数学。”中定义了一些数学函数和宏,用来实现不同种类的数学运算。下面给出数学。”中标准数学函数的函数定义及功能简介,见下表。中定义的函数数学。函数定义函数功能简介双 输 出(双X);指数运算函数,求E的X次塞函数双 对 数(双x)对数函数I n (x)双 l o g l O (x);对数函数日志双 武 器(双x,双Y);指 数 函 数(X,丫的次方)双 s q r t (x);计算平方根函数双 细 胞(x);向上舍入函数双 层(双X);向下舍入函数双 晶 圆 厂(X);求浮点数的绝对值双 I d e x p (d o u b l e x,i n t n);装载浮点数函数双 f r e x p (d o u b l e x,i n t *口);分解浮点数函数双 修 正(x的 双I P);分解双精度数函数双 F MO D (x,y);求模函数双 罪(

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业/管理/HR > 营销创新

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号