fbpx
维基百科

C標準函式庫

C 標準函式庫C standard library,缩写:libc)是在C語言程式設計中,所有符合標準的头文件head file)的集合,以及常用的函式庫實作程序(如 I/O 輸入輸出字串控制)。不像 COBOLFortranPL/I程式語言,在 C 語言的工作任務裡不會包含嵌入的關鍵字,所以幾乎所有的 C 語言程式都是由標準函式庫的函式來建立的。

設計

每一個函式的名稱與特性會被寫成一個電腦檔案,這個檔案就稱為標頭檔案,但是實際的函式實作是被分存到函式庫檔案裡。標頭檔的命名和領域是很常見的,但是函式庫的組織架構也會因為不同的編譯器而有所不同。標準函式庫通常會隨附在編譯器上。因為 C 編譯器常會提供一些額外的非 ANSI C 函式功能,所以某個隨附在特定編譯器上的標準函式庫,對其他不同的編譯器來說,是不相容的。

設計品質

大多数 C 標準函式庫設計得很好。有些少部分會為了商業優勢和利益,把某些舊函式視同錯誤或提出警告。字串輸入函式 gets()scanf() 讀取字串輸入的使用是很多緩衝區溢位的原因,大多数的程式設計指南會建議避免使用。另一個較為奇特的函式是 strtok(),它原本是作為早期的词法分析用途,但是它非常容易出錯(fragile),而且很難使用。

历史沿革

ANSI C共包括15個標頭檔。1995年,Normative Addendum 1NA1)批准了3个头文件(iso646.hwchar.hwctype.h)增加到C标准函数库中。C99标准增加了6个头文件(complex.hfenv.hinttypes.hstdbool.hstdint.htgmath.h)。C11标准中又新增了5个头文件(stdalign.hstdatomic.hstdnoreturn.hthreads.huchar.h)。至此,C标准函数库共有29个头文件:

名字 源自 描述
<assert.h> 包含断言,被用来在程序的调试版本中帮助检测逻辑错误以及其他类型的bug。
<complex.h> C99 一组操作复数的函数。
<ctype.h> 定义了一组函数,用来根据类型来给字符分类,或者进行大小写转换,而不关心所使用的字符集(通常是ASCII或其扩展字符集,也有EBCDIC)。
<errno.h> 用来测试由库函数报的错误代码。
<fenv.h> C99 定义了一组用来控制浮点数环境的函数。
<float.h> 定义了用于浮点数库特定实现的宏常量。
<inttypes.h> C99 定义精确的宽度整数类型。
<iso646.h> NA1 定义几个等效于C中某些运算符的宏。用于使用ISO 646变体字符集进行编程。
<limits.h> 定义了用于整数库特定实现属性的宏常量。
<locale.h> 定义C语言本地化函数。
<math.h> 定义C语言数学函数。
<setjmp.h> 定义了巨集setjmplongjmp,在非局部跳转的时候使用。
<signal.h> 定义C语言信号处理函数。
<stdalign.h> C11 用于查询和指定对象的数据结构对齐方式。
<stdarg.h> 用于查询和指定对象的数据结构对齐方式。
<stdatomic.h> C11 用于查询和指定对象的数据结构对齐方式。
<stdbool.h> C99 定义布尔数据类型。
<stddef.h> 定义了几个常见的类型与巨集
<stdint.h> C99 定义精确的宽度整数类型。
<stdio.h> 定义输入输出函数。
<stdlib.h> 定义数值转换函数,伪随机数生成函数,动态内存分配函数,过程控制函数。
<stdnoreturn.h> C11 For specifying non-returning functions.
<string.h> 定义C语言字符串处理函数。
<tgmath.h> C99 Defines type-generic mathematical functions.
<threads.h> C11 Defines functions for managing multiple threads as well as mutexes and condition variables.
<time.h> Defines date and time handling functions
<uchar.h> C11 Types and functions for manipulating Unicode characters.
<wchar.h> NA1 Defines wide string handling functions.
<wctype.h> NA1 Defines set of functions used to classify wide characters by their types or to convert between upper and lower case

参考文献

外部連結

  • :A detailed description of the header files
  • Microsoft C Run-Time Libraries(页面存档备份,存于互联网档案馆) on MSDN
  • Coding Programmer Page(页面存档备份,存于互联网档案馆) [Coding Programmer Page / Library Reference and Examples] (english) ]

参见

c標準函式庫, 標準函式庫, standard, library, 缩写, libc, 是在c語言程式設計中, 所有符合標準的头文件, head, file, 的集合, 以及常用的函式庫實作程序, 輸入輸出和字串控制, 不像, cobol, fortran, i等程式語言, 語言的工作任務裡不會包含嵌入的關鍵字, 所以幾乎所有的, 語言程式都是由標準函式庫的函式來建立的, 目录, 設計, 設計品質, 历史沿革, 参考文献, 外部連結, 参见設計, 编辑每一個函式的名稱與特性會被寫成一個電腦檔案, 這個檔案就稱為標頭. C 標準函式庫 C standard library 缩写 libc 是在C語言程式設計中 所有符合標準的头文件 head file 的集合 以及常用的函式庫實作程序 如 I O 輸入輸出和字串控制 不像 COBOL Fortran 和 PL I等程式語言 在 C 語言的工作任務裡不會包含嵌入的關鍵字 所以幾乎所有的 C 語言程式都是由標準函式庫的函式來建立的 目录 1 設計 1 1 設計品質 2 历史沿革 3 参考文献 4 外部連結 5 参见設計 编辑每一個函式的名稱與特性會被寫成一個電腦檔案 這個檔案就稱為標頭檔案 但是實際的函式實作是被分存到函式庫檔案裡 標頭檔的命名和領域是很常見的 但是函式庫的組織架構也會因為不同的編譯器而有所不同 標準函式庫通常會隨附在編譯器上 因為 C 編譯器常會提供一些額外的非 ANSI C 函式功能 所以某個隨附在特定編譯器上的標準函式庫 對其他不同的編譯器來說 是不相容的 設計品質 编辑 大多数 C 標準函式庫設計得很好 有些少部分會為了商業優勢和利益 把某些舊函式視同錯誤或提出警告 字串輸入函式 gets 及 scanf 讀取字串輸入的使用是很多緩衝區溢位的原因 大多数的程式設計指南會建議避免使用 另一個較為奇特的函式是 strtok 它原本是作為早期的词法分析用途 但是它非常容易出錯 fragile 而且很難使用 历史沿革 编辑ANSI C共包括15個標頭檔 1995年 Normative Addendum 1 NA1 批准了3个头文件 iso646 h wchar h和wctype h 增加到C标准函数库中 C99标准增加了6个头文件 complex h fenv h inttypes h stdbool h stdint h和tgmath h C11标准中又新增了5个头文件 stdalign h stdatomic h stdnoreturn h threads h和uchar h 至此 C标准函数库共有29个头文件 名字 源自 描述 a href Assert h html title Assert h lt assert h gt a 包含断言 被用来在程序的调试版本中帮助检测逻辑错误以及其他类型的bug a href Complex h html title Complex h lt complex h gt a C99 一组操作复数的函数 a href Ctype h html title Ctype h lt ctype h gt a 定义了一组函数 用来根据类型来给字符分类 或者进行大小写转换 而不关心所使用的字符集 通常是ASCII或其扩展字符集 也有EBCDIC a href Errno h html title Errno h lt errno h gt a 用来测试由库函数报的错误代码 a href Fenv h html title Fenv h lt fenv h gt a C99 定义了一组用来控制浮点数环境的函数 a href Float h html title Float h lt float h gt a 定义了用于浮点数库特定实现的宏常量 a href Inttypes h html title Inttypes h lt inttypes h gt a C99 定义精确的宽度整数类型 a href Iso646 h html class mw redirect title Iso646 h lt iso646 h gt a NA1 定义几个等效于C中某些运算符的宏 用于使用ISO 646变体字符集进行编程 a href Limits h html title Limits h lt limits h gt a 定义了用于整数库特定实现属性的宏常量 a href Locale h html title Locale h lt locale h gt a 定义C语言本地化函数 a href Math h html title Math h lt math h gt a 定义C语言数学函数 a href Setjmp h html title Setjmp h lt setjmp h gt a 定义了巨集setjmp和longjmp 在非局部跳转的时候使用 a href Signal h html title Signal h lt signal h gt a 定义C语言信号处理函数 a href Stdalign h html title Stdalign h lt stdalign h gt a C11 用于查询和指定对象的数据结构对齐方式 a href Stdarg h html title Stdarg h lt stdarg h gt a 用于查询和指定对象的数据结构对齐方式 lt stdatomic h gt C11 用于查询和指定对象的数据结构对齐方式 a href Stdbool h html title Stdbool h lt stdbool h gt a C99 定义布尔数据类型 a href Stddef h html title Stddef h lt stddef h gt a 定义了几个常见的类型与巨集 a href Stdint h html title Stdint h lt stdint h gt a C99 定义精确的宽度整数类型 a href Stdio h html title Stdio h lt stdio h gt a 定义输入输出函数 a href Stdlib h html title Stdlib h lt stdlib h gt a 定义数值转换函数 伪随机数生成函数 动态内存分配函数 过程控制函数 lt stdnoreturn h gt C11 For specifying non returning functions a href String h html title String h lt string h gt a 定义C语言字符串处理函数 a href Tgmath h html title Tgmath h lt tgmath h gt a C99 Defines type generic mathematical functions lt threads h gt C11 Defines functions for managing multiple threads as well as mutexes and condition variables a href Time h html title Time h lt time h gt a Defines date and time handling functions a href Uchar h html title Uchar h lt uchar h gt a C11 Types and functions for manipulating Unicode characters a href Wchar h html title Wchar h lt wchar h gt a NA1 Defines wide string handling functions a href Wctype h html class mw redirect title Wctype h lt wctype h gt a NA1 Defines set of functions used to classify wide characters by their types or to convert between upper and lower case参考文献 编辑外部連結 编辑The C Standard Library A detailed description of the header files The C Library Reference Guide Microsoft C Run Time Libraries 页面存档备份 存于互联网档案馆 on MSDN Coding Programmer Page 页面存档备份 存于互联网档案馆 Coding Programmer Page Library Reference and Examples english 参见 编辑 软件主题 计算机程序设计主题 GNU C 函式庫 C 標準程式庫 C POSIX library 取自 https zh wikipedia org w index php title C標準函式庫 amp oldid 70373248, 维基百科,wiki,书籍,书籍,图书馆,

文章

,阅读,下载,免费,免费下载,mp3,视频,mp4,3gp, jpg,jpeg,gif,png,图片,音乐,歌曲,电影,书籍,游戏,游戏。