<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://www.vigyanwiki.in/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=2804%3A540%3A19C%3A400%3AC041%3A8B1D%3ABCBE%3ACF06</id>
	<title>Vigyanwiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://www.vigyanwiki.in/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=2804%3A540%3A19C%3A400%3AC041%3A8B1D%3ABCBE%3ACF06"/>
	<link rel="alternate" type="text/html" href="https://www.vigyanwiki.in/wiki/Special:Contributions/2804:540:19C:400:C041:8B1D:BCBE:CF06"/>
	<updated>2026-05-10T11:09:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://www.vigyanwiki.in/index.php?title=C_standard_library&amp;diff=224621</id>
		<title>C standard library</title>
		<link rel="alternate" type="text/html" href="https://www.vigyanwiki.in/index.php?title=C_standard_library&amp;diff=224621"/>
		<updated>2023-07-23T11:34:12Z</updated>

		<summary type="html">&lt;p&gt;2804:540:19C:400:C041:8B1D:BCBE:CF06: Link to stdlib.h wiki page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Short description|Standard library for the C programming language}}&lt;br /&gt;
{{C Standard Library}}&lt;br /&gt;
The '''C standard library''' or '''libc''' is the [[standard library]] for the [[C (programming language)|C programming language]], as specified in the [[ISO C]] standard.&amp;lt;ref name=&amp;quot;c17io&amp;quot;&amp;gt;[[International Organization for Standardization|ISO]]/[[International Electrotechnical Commission|IEC]] (2018). ''[[C17_(C_standard_revision)|ISO/IEC 9899:2018(E): Programming Languages - C]] §7''&amp;lt;/ref&amp;gt; Starting from the original [[ANSI C]] standard, it was developed at the same time as [[C POSIX library|the C library POSIX specification]], which is a superset of it.&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
 | url = http://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_chapter/libc_1.html&lt;br /&gt;
 | title = The GNU C Library – Introduction&lt;br /&gt;
 | access-date = 2013-12-05&lt;br /&gt;
 | website = gnu.org&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
 | url = https://stackoverflow.com/questions/9376837/difference-bewteen-c-standard-library-and-c-posix-library&lt;br /&gt;
 | title = Difference between C standard library and C POSIX library&lt;br /&gt;
 | year = 2012 | access-date = 2015-03-04&lt;br /&gt;
 | website = stackoverflow.com&lt;br /&gt;
}}&amp;lt;/ref&amp;gt; Since ANSI C was adopted by the [[International Organization for Standardization]],&amp;lt;ref name=&amp;quot;ISOAdoptedAnsiC&amp;quot;&amp;gt;{{cite web |title=C Standards |url=http://www.keil.com/support/docs/1893.htm |url-status=live |access-date=24 November 2011 |website=C: C Standards |publisher=Keil |language=en-US}}&amp;lt;/ref&amp;gt; the C standard library is also called the '''ISO C library'''.&lt;br /&gt;
&lt;br /&gt;
The C standard library provides [[macro (computer science)|macro]]s, [[Data type|type]] definitions and functions for tasks such as [[character string (computer science)|string]] handling, mathematical computations, input/output processing, [[memory management]], and several other [[operating system]] services.&lt;br /&gt;
&lt;br /&gt;
== Application programming interface (API) ==&lt;br /&gt;
&lt;br /&gt;
=== {{Anchor|headers}}Header files ===&lt;br /&gt;
 &lt;br /&gt;
The [[application programming interface]] (API) of the C standard library is declared in a number of [[header file]]s. Each header file contains one or more function declarations, data type definitions, and macros.&lt;br /&gt;
&lt;br /&gt;
After a long period of stability, three new header files (&amp;lt;code&amp;gt;iso646.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;wchar.h&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;wctype.h&amp;lt;/code&amp;gt;) were added with ''Normative Addendum 1'' (NA1), an addition to the C Standard ratified in 1995. Six more header files (&amp;lt;code&amp;gt;complex.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;fenv.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;inttypes.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdbool.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdint.h&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;tgmath.h&amp;lt;/code&amp;gt;) were added with [[C99]], a revision to the C Standard published in 1999, and five more files (&amp;lt;code&amp;gt;stdalign.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdatomic.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdnoreturn.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;threads.h&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;uchar.h&amp;lt;/code&amp;gt;) with [[C11 (C standard revision)|C11]] in 2011. In total, there are now 29 header files:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! From !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[assert.h|&amp;lt;assert.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Contains the [[assertion (computing)|assert]] macro, used to assist with detecting logical errors and other types of bugs in debugging versions of a program.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[complex.h|&amp;lt;complex.h&amp;gt;]]&amp;lt;/code&amp;gt; || C99 || A [[C mathematical functions#complex.h|set of functions]] for manipulating [[complex number]]s.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[ctype.h|&amp;lt;ctype.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Defines [[C character classification|set of functions]] used to classify characters by their types or to convert between upper and lower case in a way that is independent of the used [[character set]] (typically [[ASCII]] or one of its extensions, although implementations utilizing [[EBCDIC]] are also known).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[errno.h|&amp;lt;errno.h&amp;gt;]]&amp;lt;/code&amp;gt; || || For testing error codes reported by library functions.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[fenv.h|&amp;lt;fenv.h&amp;gt;]]&amp;lt;/code&amp;gt; || C99 || Defines a [[C mathematical functions#fenv.h|set of functions]] for controlling [[floating-point]] environment.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[float.h|&amp;lt;float.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Defines [[C data types#float.h|macro constants]] specifying the implementation-specific properties of the [[floating-point]] library.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[inttypes.h|&amp;lt;inttypes.h&amp;gt;]]&amp;lt;/code&amp;gt; || C99 || Defines [[C data types#inttypes.h|exact-width integer types]].&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[iso646.h|&amp;lt;iso646.h&amp;gt;]]&amp;lt;/code&amp;gt; || NA1 || Defines [[C alternative tokens|several macros]] that implement alternative ways to express several standard tokens. For programming in [[ISO 646]] variant character sets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[limits.h|&amp;lt;limits.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Defines [[C data types#limits.h|macro constants]] specifying the implementation-specific properties of the integer types.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;locale.h&amp;gt;&amp;lt;/code&amp;gt; || || Defines [[C localization functions|localization functions]].&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[math.h|&amp;lt;math.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Defines [[C mathematical functions|common mathematical functions]].&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[setjmp.h|&amp;lt;setjmp.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Declares the macros &amp;lt;code&amp;gt;setjmp&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;longjmp&amp;lt;/code&amp;gt;, which are used for non-local exits.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[signal.h|&amp;lt;signal.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Defines [[C signal handling|signal-handling functions]].&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;stdalign.h&amp;gt;&amp;lt;/code&amp;gt; || C11 || For querying and specifying the [[Data structure alignment|alignment]] of objects.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[stdarg.h|&amp;lt;stdarg.h&amp;gt;]]&amp;lt;/code&amp;gt; || || For accessing a varying number of arguments passed to functions.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;stdatomic.h&amp;gt;&amp;lt;/code&amp;gt; || C11 || For [[Linearizability|atomic operations]] on data shared between threads.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[stdbool.h|&amp;lt;stdbool.h&amp;gt;]]&amp;lt;/code&amp;gt; || C99 || Defines [[C data types#stdbool.h|a boolean data type]].&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[stddef.h|&amp;lt;stddef.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Defines [[C data types#stddef.h|several useful types and macros]].&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[stdint.h|&amp;lt;stdint.h&amp;gt;]]&amp;lt;/code&amp;gt; || C99 || Defines [[C data types#stdint.h|exact-width integer types]].&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[stdio.h|&amp;lt;stdio.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Defines [[C file input/output|core input and output functions]]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[stdlib.h|&amp;lt;stdlib.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Defines [[C string handling#stdlib.h|numeric conversion functions]], [[C mathematical functions#stdlib.h|pseudo-random numbers generation functions]], [[C dynamic memory allocation|memory allocation]], [[C process control|process control functions]]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;stdnoreturn.h&amp;gt;&amp;lt;/code&amp;gt; || C11 || For specifying non-returning functions&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[string.h|&amp;lt;string.h&amp;gt;]]&amp;lt;/code&amp;gt; || || Defines [[C string handling|string-handling functions]]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[tgmath.h|&amp;lt;tgmath.h&amp;gt;]]&amp;lt;/code&amp;gt; || C99 || Defines [[C mathematical functions#tgmath.h|type-generic mathematical functions]].&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;threads.h&amp;gt;&amp;lt;/code&amp;gt; || C11 || Defines functions for managing multiple [[Thread (computer science)|threads]], [[Mutual exclusion|mutexes]] and [[Monitor (synchronization)|condition variables]]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[time.h|&amp;amp;lt;time.h&amp;amp;gt;]]&amp;lt;/code&amp;gt; || || Defines [[C date and time functions|date- and time-handling functions]]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;uchar.h&amp;gt;&amp;lt;/code&amp;gt; || C11 || Types and functions for manipulating [[Unicode]] characters&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[wchar.h|&amp;lt;wchar.h&amp;gt;]]&amp;lt;/code&amp;gt; || NA1 || Defines [[C string handling|wide-string-handling functions]]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[[wctype.h|&amp;lt;wctype.h&amp;gt;]]&amp;lt;/code&amp;gt; || NA1 || Defines [[C character classification|set of functions]] used to classify wide characters by their types or to convert between upper and lower case&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Three of the header files (&amp;lt;code&amp;gt;complex.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdatomic.h&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;threads.h&amp;lt;/code&amp;gt;) are conditional features that implementations are not required to support.&lt;br /&gt;
&lt;br /&gt;
The [[POSIX]] standard added several nonstandard C headers for Unix-specific functionality. Many have found their way to other architectures. Examples include &amp;lt;code&amp;gt;[[fcntl.h]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[unistd.h]]&amp;lt;/code&amp;gt;. A number of other groups are using other nonstandard headers – the [[GNU C Library]] has &amp;lt;code&amp;gt;alloca.h&amp;lt;/code&amp;gt;, and HP [[OpenVMS]] has the &amp;lt;code&amp;gt;va_count()&amp;lt;/code&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
On Unix-like systems, the authoritative documentation of the actually implemented API is provided in the form of [[man page]]s. On most systems, man pages on standard library functions are in section&amp;amp;nbsp;3; section&amp;amp;nbsp;7 may contain some more generic pages on underlying concepts (e.g. &amp;lt;code&amp;gt;man 7 math_error&amp;lt;/code&amp;gt; in [[Linux]]).&lt;br /&gt;
&lt;br /&gt;
== Implementations ==&lt;br /&gt;
[[Unix-like]] systems typically have a C library in [[shared library]] form, but the header files (and compiler toolchain) may be absent from an installation so C development may not be possible. The C library is considered part of the operating system on Unix-like systems. The C functions, including the ISO C standard ones, are widely used by programs, and are regarded as if they were not only an implementation of something in the C language, but also ''de facto'' part of the operating system interface. Unix-like operating systems generally cannot function if the C library is erased. This is true for applications which are dynamically as opposed to statically linked. Further, the kernel itself (at least in the case of Linux) operates independently of any libraries. &lt;br /&gt;
&lt;br /&gt;
On Microsoft Windows, the core system dynamic libraries ([[dynamic-link library|DLLs]]) provide an implementation of the C standard library for the [[Microsoft Visual&amp;amp;nbsp;C++]] compiler v6.0; the C standard library for newer versions of the Microsoft Visual&amp;amp;nbsp;C++ compiler is provided by each compiler individually, as well as ''redistributable'' packages. Compiled applications written in C are either statically linked with a C library, or linked to a dynamic version of the library that is shipped with these applications, rather than relied upon to be present on the targeted systems. Functions in a compiler's C library are not regarded as interfaces to Microsoft Windows.&lt;br /&gt;
&lt;br /&gt;
Many other implementations exist, provided with both various operating systems and C compilers.  Some of the popular implementations are the following:&lt;br /&gt;
&lt;br /&gt;
* The [[BSD libc]], various implementations distributed with [[Berkeley Software Distribution|BSD]]-derived operating systems&lt;br /&gt;
* [[GNU C Library]] (glibc), used in [[GNU Hurd]], [[GNU/kFreeBSD]] and [[Linux]]&lt;br /&gt;
* [[Windows library files#CRT|Microsoft C run-time library]], part of [[Microsoft Visual C++]]. There are two versions of the library: MSVCRT that was a redistributable till v12 / Visual Studio 2013 with low C99 compliance, and a new one UCRT (Universal C Run Time) that is part of Windows 10 and 11, so always present to link against, and is C99 compliant too[https://learn.microsoft.com/en-us/cpp/porting/upgrade-your-code-to-the-universal-crt?view=msvc-170].&lt;br /&gt;
* [[dietlibc]], an alternative small implementation of the C standard library (MMU-less)&lt;br /&gt;
* [[uClibc|μClibc]], a C standard library for embedded [[μClinux]] systems (MMU-less)&lt;br /&gt;
** [[uClibc|uclibc-ng]], an embedded C library, fork of μClibc, still maintained, with [[memory management unit]] (MMU) support&lt;br /&gt;
* [[Newlib]], a C standard library for embedded systems (MMU-less)&amp;lt;ref&amp;gt;{{cite web |url=http://www.cygwin.com/ml/newlib/2006/msg00224.html |title=Re: Does Newlib support mmu-less CPUs? |publisher=Cygwin.com |date=23 March 2006 |access-date=28 October 2011 |archive-url=https://web.archive.org/web/20081122063741/http://www.cygwin.com/ml/newlib/2006/msg00224.html |archive-date=22 November 2008 |url-status=dead }}&amp;lt;/ref&amp;gt; and used in the [[Cygwin]] GNU distribution for Windows&lt;br /&gt;
* [[klibc]], primarily for booting Linux systems&lt;br /&gt;
* [[musl]], another lightweight C standard library implementation for Linux systems&amp;lt;ref&amp;gt;{{cite web|url=http://www.etalabs.net/musl/ |title=musl libc |publisher=Etalabs.net |access-date=28 October 2011}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* [[Bionic (software)|Bionic]], originally developed by Google for the Android embedded system operating system, derived from BSD libc&lt;br /&gt;
* [https://keithp.com/picolibc picolibc], developed by [[Keith Packard]], targeting small embedded systems with limited RAM, based on code from [[Newlib]] and [https://www.nongnu.org/avr-libc/ AVR Libc]&lt;br /&gt;
&lt;br /&gt;
=== Compiler built-in functions ===&lt;br /&gt;
Some compilers (for example, [[GNU Compiler Collection|GCC]]&amp;lt;ref&amp;gt;[https://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Other-Builtins.html#Other-Builtins Other built-in functions provided by GCC], GCC Manual&amp;lt;/ref&amp;gt;) provide built-in versions of many of the functions in the C standard library; that is, the implementations of the functions are written into the compiled [[object file]], and the program calls the built-in versions instead of the functions in the C library [[shared object]] file. This reduces function-call overhead, especially if function calls are replaced with [[inline function|inline]] variants, and allows other forms of [[compiler optimization|optimization]] (as the compiler knows the [[control flow|control-flow]] characteristics of the built-in variants), but may cause confusion when debugging (for example, the built-in versions cannot be replaced with [[instrumentation (computer programming)|instrumented]] variants).&lt;br /&gt;
&lt;br /&gt;
However, the built-in functions must behave like ordinary functions in accordance with ISO C. The main implication is that the program must be able to create a pointer to these functions by taking their address, and invoke the function by means of that pointer. If two pointers to the same function are derived in two different translation units in the program, these two pointers must compare equal; that is, the address comes by resolving the name of the function, which has external (program-wide) linkage.&lt;br /&gt;
&lt;br /&gt;
=== Linking, libm ===&lt;br /&gt;
&lt;br /&gt;
Under FreeBSD&amp;lt;ref&amp;gt;{{cite web|title=Compiling with cc|url=http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/tools-compiling.html|access-date=2013-03-02}}&amp;lt;/ref&amp;gt; and glibc,&amp;lt;ref&amp;gt;{{cite web |last1=Weimer |first1=Florian |title=c - What functions is the libm intended for? |url=https://stackoverflow.com/questions/54054925/what-functions-is-the-libm-intended-for |website=Stack Overflow |access-date=24 February 2021}}&amp;lt;/ref&amp;gt; some functions such as sin() are not linked in by default and are instead bundled in the mathematical library [[libm]]. If any of them are used, the linker must be given the directive &amp;lt;code&amp;gt;-lm&amp;lt;/code&amp;gt;. POSIX requires that the c99 compiler supports &amp;lt;code&amp;gt;-lm&amp;lt;/code&amp;gt;, and that the functions declared in the headers &amp;lt;code&amp;gt;math.h&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;complex.h&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;fenv.h&amp;lt;/code&amp;gt; are available for linking if &amp;lt;code&amp;gt;-lm&amp;lt;/code&amp;gt; is specified, but does not specify if the functions are linked by default.&amp;lt;ref&amp;gt;{{cite web |title=c99 - compile standard C programs |url=https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html |website=The Open Group Base Specifications Issue 7, 2018 edition |publisher=The Open Group |access-date=24 February 2021}}&amp;lt;/ref&amp;gt; musl satisfies this requirement by putting everything into a single libc library and providing an empty libm.&amp;lt;ref&amp;gt;{{cite web |title=musl FAQ |url=https://www.musl-libc.org/faq.html |website=www.musl-libc.org |access-date=24 February 2021}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Detection ===&lt;br /&gt;
According to the C standard the macro &amp;lt;code&amp;gt;__STDC_HOSTED__&amp;lt;/code&amp;gt; shall be defined to '''1''' if the implementation is hosted. A hosted implementation has all the headers specified by the C standard. An implementation can also be ''freestanding'' which means that these headers will not be present. If an implementation is ''freestanding'', it shall define &amp;lt;code&amp;gt;__STDC_HOSTED__&amp;lt;/code&amp;gt; to '''0'''.&lt;br /&gt;
&lt;br /&gt;
== Problems and workarounds ==&lt;br /&gt;
&lt;br /&gt;
=== {{Anchor|BUFFER-OVERFLOW}}Buffer overflow vulnerabilities ===&lt;br /&gt;
Some functions in the C standard library have been notorious for having [[buffer overflow]] vulnerabilities and generally encouraging buggy programming ever since their adoption.{{efn|[[Morris worm]] that takes advantage of the well-known vulnerability in &amp;lt;code&amp;gt;gets()&amp;lt;/code&amp;gt; have been created as early as in 1988.}} The most criticized items are:&lt;br /&gt;
* [[C string handling|string-manipulation routines]], including &amp;lt;code&amp;gt;strcpy()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;strcat()&amp;lt;/code&amp;gt;, for lack of [[bounds checking]] and possible buffer overflows if the bounds aren't checked manually;&lt;br /&gt;
* string routines in general, for [[side effect (computer science)|side-effects]], encouraging irresponsible buffer usage, not always guaranteeing valid [[null-terminated string|null-terminated]] output, linear length calculation;{{efn|in C standard library, string length calculation and looking for a string's end have [[Linear time|linear time complexities]] and are inefficient when used on the same or related strings repeatedly}}&lt;br /&gt;
* &amp;lt;code&amp;gt;[[printf]]()&amp;lt;/code&amp;gt; family of routines, for spoiling the [[call stack|execution stack]] when the format string doesn't match the arguments given. This fundamental flaw created an entire class of attacks: [[format string attack]]s;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[gets()|gets]]()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[scanf]]()&amp;lt;/code&amp;gt; family of I/O routines, for lack of (either any or easy) input length checking.&lt;br /&gt;
&lt;br /&gt;
Except the extreme case with &amp;lt;code&amp;gt;gets()&amp;lt;/code&amp;gt;, all the security vulnerabilities can be avoided by introducing auxiliary code to perform memory management, bounds checking, input checking, etc. This is often done in the form of wrappers that make standard library functions safer and easier to use. This dates back to as early as ''[[The Practice of Programming]]'' book by B. Kernighan and R. Pike where the authors commonly use wrappers that print error messages and quit the program if an error occurs.&lt;br /&gt;
&lt;br /&gt;
The ISO C committee published Technical reports TR 24731-1&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
 | url = http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1225.pdf&lt;br /&gt;
 | title = ISO/IEC TR 24731-1: Extensions to the C Library, Part I: Bounds-checking interfaces&lt;br /&gt;
 | date = 2007-03-28 | access-date = 2014-03-13&lt;br /&gt;
 | publisher = open-std.org }}&amp;lt;/ref&amp;gt; and is working on TR 24731-2&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
 | url = http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1337.pdf&lt;br /&gt;
 | title = ISO/IEC WDTR 24731-2: Extensions to the C Library, Part II: Dynamic Allocation Functions&lt;br /&gt;
 | date = 2008-08-10 | access-date = 2014-03-13&lt;br /&gt;
 | publisher = open-std.org }}&amp;lt;/ref&amp;gt; to propose adoption of some functions with bounds checking and automatic buffer allocation, correspondingly. The former has met severe criticism with some praise,&amp;lt;ref&amp;gt;[https://stackoverflow.com/questions/372980/do-you-use-the-tr-24731-safe-functions-in-your-c-code Do you use the TR 24731 'safe' functions in your C code?] - Stack overflow&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1106.txt |title=Austin Group Review of ISO/IEC WDTR 24731 |access-date=28 October 2011}}&amp;lt;/ref&amp;gt; the latter received mixed responses. Despite this, TR 24731-1 has been implemented into Microsoft's C standard library and its compiler issues warnings when using old &amp;quot;insecure&amp;quot; functions.&lt;br /&gt;
&lt;br /&gt;
=== Threading problems, vulnerability to race conditions ===&lt;br /&gt;
The &amp;lt;code&amp;gt;[[strerror]]()&amp;lt;/code&amp;gt; routine is criticized for being [[thread safety|thread unsafe]] and otherwise vulnerable to [[race condition]]s.&lt;br /&gt;
&lt;br /&gt;
=== Error handling ===&lt;br /&gt;
The error handling of the functions in the C standard library is not consistent and sometimes confusing. According to the Linux manual page &amp;lt;code&amp;gt;math_error&amp;lt;/code&amp;gt;, &amp;quot;The current (version 2.8) situation under glibc is messy. Most (but not all) functions raise exceptions on errors. Some also set ''errno''. A few functions set ''errno'', but don't raise an exception. A very few functions do neither.&amp;quot;&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
 | url = http://man7.org/linux/man-pages/man7/math_error.7.html&lt;br /&gt;
 | title = math_error - detecting errors from mathematical functions&lt;br /&gt;
 | date = 2008-08-11 | access-date = 2014-03-13&lt;br /&gt;
 | website = man7.org&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Standardization ==&lt;br /&gt;
{{Main article|C (programming language)#History|l1=C (programming language) § History}}&lt;br /&gt;
&lt;br /&gt;
The original [[C (programming language)|C language]] provided no built-in functions such as I/O operations, unlike traditional languages such as [[COBOL]] and [[Fortran]].{{Citation needed|date=November 2010}} Over time, user communities of C shared ideas and implementations of what is now called C standard libraries. Many of these ideas were incorporated eventually into the definition of the standardized C language.&lt;br /&gt;
&lt;br /&gt;
Both [[Unix]] and C were created at [[Bell Labs|AT&amp;amp;T's Bell Laboratories]] in the late 1960s and early 1970s. During the 1970s the C language became increasingly popular. Many universities and organizations began creating their own variants of the language for their own projects. By the beginning of the 1980s compatibility problems between the various C implementations became apparent. In 1983 the [[American National Standards Institute]] (ANSI) formed a committee to establish a standard specification of C known as &amp;quot;[[ANSI C]]&amp;quot;. This work culminated in the creation of the so-called C89 standard in 1989. Part of the resulting standard was a set of [[software libraries]] called the ANSI C standard library.&lt;br /&gt;
&lt;br /&gt;
=== POSIX standard library ===&lt;br /&gt;
{{Main article|C POSIX library}}&lt;br /&gt;
&lt;br /&gt;
[[POSIX]], as well as [[Single Unix Specification|SUS]], specify a number of routines that should be available over and above those in the basic C standard library. The POSIX specification includes header files for, among other uses, [[POSIX Threads|multi-threading]], [[Berkeley sockets|networking]], and [[regular expression]]s. These are often implemented alongside the C standard library functionality, with varying degrees of closeness. For example, [[glibc]] implements functions such as &amp;lt;code&amp;gt;[[fork (operating system)|fork]]&amp;lt;/code&amp;gt; within &amp;lt;code&amp;gt;libc.so&amp;lt;/code&amp;gt;, but before [[NPTL]] was merged into glibc it constituted a separate library with its own linker flag argument. Often, this POSIX-specified functionality will be regarded as part of the library; the basic C library may be identified as the ANSI or [[International Organization for Standardization|ISO]] C library.&lt;br /&gt;
&lt;br /&gt;
=== BSD libc ===&lt;br /&gt;
'''BSD libc''' is a superset of the POSIX standard library supported by the C libraries included with [[BSD]] [[operating system]]s such as [[FreeBSD]], [[NetBSD]], [[OpenBSD]] and [[macOS]]. BSD libc has some extensions that are not defined in the original standard, many of which first appeared in 1994's [[BSD#4.4BSD and descendants|4.4BSD]] release (the first to be largely developed after the first standard was issued in 1989). Some of the extensions of BSD libc are:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;sys/tree.h&amp;lt;/code&amp;gt;{{snd}} contains an implementation of [[red–black tree]] and [[splay tree]]&amp;lt;ref&amp;gt;{{cite web|url=http://man.freebsd.org/tree|title=tree |website=Man.freebsd.org |date=2007-12-27 |access-date=2013-08-25}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/sys/sys/tree.h|title=Super User's BSD Cross Reference: /OpenBSD/sys/sys/tree.h|website=bxr.su}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sys/queue.h&amp;lt;/code&amp;gt;{{snd}} implementations of [[Linked list]], [[queue (data structure)|queues]], [[tail queue]], etc.&amp;lt;ref&amp;gt;{{cite web|url=http://man.freebsd.org/queue |title=queue |website=Man.freebsd.org |date=2011-05-13 |access-date=2013-08-25}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/sys/sys/queue.h|title=Super User's BSD Cross Reference: /OpenBSD/sys/sys/queue.h|website=bxr.su}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;fgetln()&amp;lt;/code&amp;gt;{{snd}} defined in &amp;lt;code&amp;gt;stdio.h&amp;lt;/code&amp;gt;. This can be used to read a file line by line.&amp;lt;ref&amp;gt;{{cite web|url=http://man.freebsd.org/fgetln |title=fgetln |website=Man.freebsd.org |date=1994-04-19 |access-date=2013-08-25}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/lib/libc/stdio/fgetln.c#fgetln|title=Super User's BSD Cross Reference: /OpenBSD/lib/libc/stdio/fgetln.c|website=bxr.su}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/include/stdio.h|title=Super User's BSD Cross Reference: /OpenBSD/include/stdio.h|website=bxr.su}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;fts.h&amp;lt;/code&amp;gt;{{snd}} contains some functions to traverse a file hierarchy&amp;lt;ref&amp;gt;{{cite web|url=http://man.freebsd.org/fts |title=fts|website=Man.freebsd.org |date=2012-03-18 |access-date=2013-08-25}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/include/fts.h|title=Super User's BSD Cross Reference: /OpenBSD/include/fts.h|website=bxr.su}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;db.h&amp;lt;/code&amp;gt;{{snd}} some functions to connect to the [[Berkeley DB]]&amp;lt;ref&amp;gt;{{cite web|url=http://man.freebsd.org/db |title=db|website=Man.freebsd.org |date=2010-09-10 |access-date=2013-08-25}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/include/db.h|title=Super User's BSD Cross Reference: /OpenBSD/include/db.h|website=bxr.su}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;strlcat()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;strlcpy()&amp;lt;/code&amp;gt;{{snd}} secure alternatives for &amp;lt;code&amp;gt;strncat()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;strncpy()&amp;lt;/code&amp;gt;&amp;lt;ref&amp;gt;Miller, Todd C. and Theo de Raadt. [http://www.usenix.org/events/usenix99/millert.html strlcpy and strlcat - consistent, safe, string copy and concatenation]. Proceedings of the 1999 USENIX Annual Technical Conference, June 6–11, 1999, pp. 175–178.&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/lib/libc/string/strlcat.c|title=Super User's BSD Cross Reference: /OpenBSD/lib/libc/string/strlcat.c|website=bxr.su}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/lib/libc/string/strlcpy.c|title=Super User's BSD Cross Reference: /OpenBSD/lib/libc/string/strlcpy.c|website=bxr.su}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/lib/libc/string/strncat.c|title=Super User's BSD Cross Reference: /OpenBSD/lib/libc/string/strncat.c|website=bxr.su}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/lib/libc/string/strncpy.c|title=Super User's BSD Cross Reference: /OpenBSD/lib/libc/string/strncpy.c|website=bxr.su}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;err.h&amp;lt;/code&amp;gt;{{snd}} contains some functions to print formatted error messages&amp;lt;ref&amp;gt;{{cite web|url=http://man.freebsd.org/err |title=err|website=Man.freebsd.org |date=2012-03-29 |access-date=2013-08-25}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/include/err.h|title=Super User's BSD Cross Reference: /OpenBSD/include/err.h|website=bxr.su}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;vis.h&amp;lt;/code&amp;gt;{{snd}} contains the &amp;lt;code&amp;gt;vis()&amp;lt;/code&amp;gt; function. This function is used to display non-printable characters in a visual format.&amp;lt;ref&amp;gt;{{cite web|title=vis(3)|url=http://www.freebsd.org/cgi/man.cgi?query=vis&amp;amp;sektion=3&amp;amp;apropos=0&amp;amp;manpath=FreeBSD+9.1-RELEASE|website=Man.FreeBSD.org|access-date=14 September 2013}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/lib/libc/gen/vis.c#vis|title=Super User's BSD Cross Reference: /OpenBSD/lib/libc/gen/vis.c|website=bxr.su}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://bxr.su/o/include/vis.h|title=Super User's BSD Cross Reference: /OpenBSD/include/vis.h|website=bxr.su}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The C standard library in other languages ==&lt;br /&gt;
Some languages include the functionality of the standard C library in their own libraries. The library may be adapted to better suit the language's structure, but the [[operational semantics]] are kept similar. The [[C++]] language, for example, includes the functionality of the C standard library in the [[namespace (programming)|namespace]] &amp;lt;code&amp;gt;std&amp;lt;/code&amp;gt; (e.g., &amp;lt;code&amp;gt;std::printf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;std::atoi&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;std::feof&amp;lt;/code&amp;gt;), in header files with similar names to the C ones (&amp;lt;code&amp;gt;cstdio&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cmath&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cstdlib&amp;lt;/code&amp;gt;, etc.). Other languages that take similar approaches are [[D (programming language)|D]], [[Perl]], [[Ruby (programming language)|Ruby]] and the main implementation of [[Python (programming language)|Python]] known as [[CPython]]. In Python 2, for example, the built-in file objects are defined as &amp;quot;implemented using C's &amp;lt;code&amp;gt;stdio&amp;lt;/code&amp;gt; package&amp;quot;,&amp;lt;ref&amp;gt;{{cite web|url=https://docs.python.org/library/stdtypes.html#bltin-file-objects |title=The Python Standard Library: 6.9. File Objects |publisher=Docs.python.org |access-date=28 October 2011}}&amp;lt;/ref&amp;gt; so that the available operations (open, read, write, etc.) are expected to have the same behavior as the corresponding C functions. [[Rust (programming language)|Rust]] has a crate called {{mono|libc}} which allows several C functions, structs, and other type definitions to be used.&amp;lt;ref&amp;gt;{{cite web|url=https://doc.rust-lang.org/nightly/libc/index.html|title=libc|work=Rust Crates|access-date=31 July 2016|archive-url=https://web.archive.org/web/20160818050524/https://doc.rust-lang.org/nightly/libc/index.html|archive-date=18 August 2016|url-status=dead}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Comparison to standard libraries of other languages ==&lt;br /&gt;
The C standard library is small compared to the standard libraries of some other languages. The C library provides a basic set of mathematical functions, string manipulation, [[Type conversion|type conversions]], and file and console-based I/O. It does not include a standard set of &amp;quot;[[container (data structure)|container types]]&amp;quot; like the [[C++]] [[Standard Template Library]], let alone the complete [[graphical user interface]] (GUI) toolkits, networking tools, and profusion of other functionality that [[Java (software platform)|Java]] and the [[.NET Framework]] provide as standard. The main advantage of the small standard library is that providing a working ISO C environment is much easier than it is with other languages, and consequently porting C to a new platform is comparatively easy.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[C++ Standard Library]]&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
{{Notelist}}&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{Reflist|30em}}&lt;br /&gt;
&lt;br /&gt;
== Further reading ==&lt;br /&gt;
* {{cite book |last=Plauger |first=P.J. |author-link=P. J. Plauger |title=The Standard C library |edition=1 |year=1992 |publisher=Prentice Hall |isbn=978-0131315099}}&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
*[https://web.archive.org/web/20150118141700/http://www.acm.uiuc.edu/webmonkeys/book/c_guide/index.html The C Library Reference Guide]&lt;br /&gt;
*[http://www.schweikhardt.net/identifiers.html Handy list of which headers are in which standard]&lt;br /&gt;
* Microsoft [https://docs.microsoft.com/en-us/cpp/c-runtime-library/run-time-routines-by-category Universal C runtime routines by category] on MSDN&lt;br /&gt;
* NetBSD [http://netbsd.gw.com/cgi-bin/man-cgi?intro+3+NetBSD-current C libraries manual] {{Webarchive|url=https://web.archive.org/web/20151223092755/http://netbsd.gw.com/cgi-bin/man-cgi?intro+3+NetBSD-current |date=2015-12-23 }} and [http://BXR.SU/NetBSD/lib/libc/ full C library source]&lt;br /&gt;
* [http://man.cat-v.org/unix-1st/3/ Manual pages for the original C standard libraries in Unix]&lt;br /&gt;
&lt;br /&gt;
{{C programming language|state=expanded}}&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:C Standard Library}}&lt;br /&gt;
[[Category:C standard library| ]]&lt;br /&gt;
[[Category:C (programming language)]]&lt;/div&gt;</summary>
		<author><name>2804:540:19C:400:C041:8B1D:BCBE:CF06</name></author>
	</entry>
</feed>