Knowledge

C standard library

Source 📝

3206: 1345:
The ISO C committee published Technical reports TR 24731-1 and is working on TR 24731-2 to propose adoption of some functions with bounds checking and automatic buffer allocation, correspondingly. The former has met severe criticism with some praise, the latter received mixed responses. Despite this,
995:
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; in addition to functions specified by the C standard, it includes other functions that are part
1179:
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
1020:
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
1426:
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
1004:
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
1336:, 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 1063:. 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 1738:
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.
1490:
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
1415:. 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. 1180:
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.
1000:
standard. The C library 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
1216:
is specified, but does not specify if the functions are linked by default. musl satisfies this requirement by putting everything into a single libc library and providing an empty libm.
1460:, 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, 1711:
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,
1632:
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
972:. On most systems, man pages on standard library functions are in section 3; section 7 may contain some more generic pages on underlying concepts (e.g. 1152:) 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 1024:
Many C library implementations exist, provided with both various operating systems and C compilers. Some of the popular implementations are the following:
1016:
compiler v6.0; the C standard library for newer versions of the Microsoft Visual C++ compiler is provided by each compiler individually, as well as
2733: 932:
standard added several nonstandard C headers for Unix-specific functionality. Many have found their way to other architectures. Examples include
1806: 1492: 213: 1695:
package", so that the available operations (open, read, write, etc.) are expected to have the same behavior as the corresponding C functions.
1172:
characteristics of the built-in variants), but may cause confusion when debugging (for example, the built-in versions cannot be replaced with
1377:
The error handling of the functions in the C standard library is not consistent and sometimes confusing. According to the Linux manual page
1342:
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.
2528: 1562: 171: 1346:
TR 24731-1 has been implemented into Microsoft's C standard library and its compiler issues warnings when using old "insecure" functions.
2693: 2672: 1853: 1232:
if the implementation is hosted. A hosted implementation has all the headers specified by the C standard. An implementation can also be
1188:
Under FreeBSD and glibc, some functions such as sin() are not linked in by default and are instead bundled in the mathematical library
1810: 1064: 1381:, "The current (version 2.8) situation under glibc is messy. Most (but not all) functions raise exceptions on errors. Some also set 2108: 1533:
release (the first to be largely developed after the first standard was issued in 1989). Some of the extensions of BSD libc are:
1904: 2611: 1173: 410:
used to classify characters by their types or to convert between upper and lower case in a way that is independent of the used
1472:. These are often implemented alongside the C standard library functionality, with varying degrees of closeness. For example, 1428: 1964: 2726: 1435:". This work culminated in the creation of the so-called C89 standard in 1989. Part of the resulting standard was a set of 232: 3046: 2683: 2656: 1985: 1265:
vulnerabilities and generally encouraging buggy programming ever since their adoption. The most criticized items are:
3237: 3210: 1529:. BSD libc has some extensions that are not defined in the original standard, many of which first appeared in 1994's 1308:
when the format string does not match the arguments given. This fundamental flaw created an entire class of attacks:
257: 164: 1951: 3027: 2936: 2719: 3145: 1288: 1033: 1684: 385: 809: 753: 3165: 3117: 1398: 1829: 452: 3232: 3175: 3160: 2866: 1696: 1680: 1338: 757: 157: 83: 1122:, originally developed by Google for the Android embedded system operating system, derived from BSD libc 3122: 2851: 1716: 904: 407: 53: 2010: 3170: 2876: 2773: 2768: 2763: 1815: 1723: 1457: 851: 834: 826: 332: 73: 3150: 2861: 2809: 2742: 2589: 1731: 1727: 1672: 1404: 629: 572: 554: 224: 197: 78: 63: 17: 264:. Each header file contains one or more function declarations, data type definitions, and macros. 3013: 2988: 1641: 1478: 1149: 1056: 3031: 2973: 1748: 1558: 1292: 1089: 1060: 1013: 749: 1633: 1165: 362: 2121: 2085: 2061: 1691:. In Python 2, for example, the built-in file objects are defined as "implemented using C's 1407:
provided no built-in functions such as I/O operations, unlike traditional languages such as
968:
On Unix-like systems, the authoritative documentation of the API is provided in the form of
2993: 2403:. Proceedings of the 1999 USENIX Annual Technical Conference, June 6–11, 1999, pp. 175–178. 1309: 1009: 907:
used to classify wide characters by their types or to convert between upper and lower case
516: 98: 2086:"ISO/IEC WDTR 24731-2: Extensions to the C Library, Part II: Dynamic Allocation Functions" 1160:
file. This reduces function-call overhead, especially if function calls are replaced with
8: 3008: 3003: 2965: 2856: 2142: 734: 68: 1156:, and the program calls the built-in versions instead of the functions in the C library 3074: 2804: 1623:
function. This function is used to display non-printable characters in a visual format.
1541: 1506:
is a superset of the POSIX standard library supported by the C libraries included with
1469: 1436: 519:
that implement alternative ways to express several standard tokens. For programming in
497: 2907: 2902: 2871: 2814: 2652: 2400: 2062:"ISO/IEC TR 24731-1: Extensions to the C Library, Part I: Bounds-checking interfaces" 1908: 1783:
in C standard library, string length calculation and looking for a string's end have
1269: 1119: 886: 791: 761: 679: 612: 236: 93: 88: 58: 2619: 716: 697: 538: 1640:
language, for example, includes the functionality of the C standard library in the
1510: 1465: 830: 474: 240: 193: 1703:
which allows several C functions, structs, and other type definitions to be used.
365:
macro, used to assist with detecting logical errors and other types of bugs while
3018: 2978: 2886: 2697: 2278: 1712: 1448: 1281: 1262: 1161: 660: 209: 1530: 3191: 3036: 2998: 2924: 2824: 2677: 1735: 1431:(ANSI) formed a committee to establish a standard specification of C known as " 1366: 1328:
family of I/O routines, for lack of (either any or easy) input length checking.
992: 478: 456: 389: 283:(NA1), an addition to the C Standard ratified in 1995. Six more header files ( 3226: 3094: 3084: 3023: 2644: 1461: 1362: 1157: 1129: 1039: 945: 925:) are conditional features that implementations are not required to support. 411: 2467: 2449: 2431: 2413: 1878: 1730:(GUI) toolkits, networking tools, and profusion of other functionality that 1613: – contains some functions to print formatted error messages 1236:
which means that these headers will not be present. If an implementation is
3064: 2829: 1169: 1047: 48: 1072:, an alternative small implementation of the C standard library (MMU-less) 3155: 2711: 2553: 1784: 1767: 1715:, and file and console-based I/O. It does not include a standard set of " 1588: 1554: 1153: 1116:, another lightweight C standard library implementation for Linux systems 261: 1291:, encouraging irresponsible buffer usage, not always guaranteeing valid 1261:
Some functions in the C standard library have been notorious for having
1132:, targeting small embedded systems with limited RAM, based on code from 541:
specifying the implementation-specific properties of the integer types.
2799: 2778: 1787:
and are inefficient when used on the same or related strings repeatedly
1581: – contains some functions to traverse a file hierarchy 1545: 1349: 1305: 1100:, a C standard library for embedded systems (MMU-less) and used in the 487: 311:, a revision to the C Standard published in 1999, and five more files ( 2468:"Super User's BSD Cross Reference: /OpenBSD/lib/libc/string/strncpy.c" 2450:"Super User's BSD Cross Reference: /OpenBSD/lib/libc/string/strncat.c" 2432:"Super User's BSD Cross Reference: /OpenBSD/lib/libc/string/strlcpy.c" 2414:"Super User's BSD Cross Reference: /OpenBSD/lib/libc/string/strlcat.c" 1706: 1079: 2401:
strlcpy and strlcat - consistent, safe, string copy and concatenation
2036: 1423: 1284:
and possible buffer overflows if the bounds are not checked manually;
988: 944:. A number of other groups are using other nonstandard headers – the 669: 375: 366: 228: 2279:"Super User's BSD Cross Reference: /OpenBSD/lib/libc/stdio/fgetln.c" 3099: 3089: 3069: 2914: 2881: 2819: 2706: 1389:, but do not raise an exception. A very few functions do neither." 1356: 1137: 1069: 1043: 1029: 969: 940: 894: 799: 782: 706: 688: 638: 603: 581: 529: 506: 353: 143: 134: 116: 2296: 2235: 1192:. If any of them are used, the linker must be given the directive 2783: 2701: 2690: 2192: 1688: 1522: 1514: 1412: 953: 934: 876: 867: 725: 646:
For accessing a varying number of arguments passed to functions.
520: 465: 428: 398: 125: 2571: 2510: 2339: 2253: 1088:, an embedded C library, fork of μClibc, still maintained, with 996:
of the operating system API, such as functions specified in the
3054: 2951: 2946: 2753: 2554:"Super User's BSD Cross Reference: /OpenBSD/lib/libc/gen/vis.c" 2382: 2210: 1930: 1518: 1432: 1316: 1299: 1133: 1101: 1097: 1085: 1075: 842: 563: 442: 419: 205: 2167: 1125: 1012:) provide an implementation of the C standard library for the 235:
handling, mathematical computations, input/output processing,
3140: 3079: 3059: 2983: 2931: 2919: 2485: 2314: 1720: 1637: 1526: 1473: 1453: 1408: 1323: 1107: 1051: 997: 977: 929: 418:
or one of its extensions, although implementations utilizing
415: 212:, which is a superset of it. Since ANSI C was adopted by the 201: 2357: 2297:"Super User's BSD Cross Reference: /OpenBSD/include/stdio.h" 2236:"Super User's BSD Cross Reference: /OpenBSD/sys/sys/queue.h" 1627: 2941: 2193:"Super User's BSD Cross Reference: /OpenBSD/sys/sys/tree.h" 2143:"math_error - detecting errors from mathematical functions" 1854:"Difference between C standard library and C POSIX library" 1676: 1487: 1419: 1189: 1113: 260:(API) of the C standard library is declared in a number of 2707:
Manual pages for the original C standard libraries in Unix
2572:"Super User's BSD Cross Reference: /OpenBSD/include/vis.h" 2511:"Super User's BSD Cross Reference: /OpenBSD/include/err.h" 2340:"Super User's BSD Cross Reference: /OpenBSD/include/fts.h" 1671:, etc.). Other languages that take similar approaches are 267:
After a long period of stability, three new header files (
246: 2758: 2383:"Super User's BSD Cross Reference: /OpenBSD/include/db.h" 1507: 1008:
On Microsoft Windows, the core system dynamic libraries (
477:
specifying the implementation-specific properties of the
308: 2109:
Do you use the TR 24731 'safe' functions in your C code?
2015:
The Open Group Base Specifications Issue 7, 2018 edition
1770:
that takes advantage of the well-known vulnerability in
436:
For testing error codes reported by library functions.
1659:), in header files with similar names to the C ones ( 1587: – some functions to connect to the 1350:
Threading problems, vulnerability to race conditions
1707:
Comparison to standard libraries of other languages
1256: 335:in 2011. In total, there are now 29 header files: 2678:Handy list of which headers are in which standard 1540: – contains an implementation of 1200:, and that the functions declared in the headers 3224: 2590:"The Python Standard Library: 6.9. File Objects" 1196:. POSIX requires that the c99 compiler supports 1816:ISO/IEC 9899:2018(E): Programming Languages - C 1575:. This can be used to read a file line by line. 208:standard, it was developed at the same time as 27:Standard library for the C programming language 1986:"c - What functions is the libm intended for?" 1871: 1143: 214:International Organization for Standardization 2727: 165: 231:definitions and functions for tasks such as 216:, the C standard library is also called the 2122:"Austin Group Review of ISO/IEC WDTR 24731" 1907:. Cygwin.com. 23 March 2006. Archived from 1600: – secure alternatives for 1251: 1032:, various implementations distributed with 2741: 2734: 2720: 754:pseudo-random numbers generation functions 172: 158: 1628:The C standard library in other languages 1442: 2684:Universal C runtime routines by category 1952:Other built-in functions provided by GCC 1905:"Re: Does Newlib support mmu-less CPUs?" 825:Defines functions for managing multiple 2643: 776:For specifying non-returning functions 247:Application programming interface (API) 14: 3225: 1774:have been created as early as in 1988. 1553: – implementations of 1224:According to the C standard the macro 991:systems typically have a C library in 597:, which are used for non-local exits. 2715: 1429:American National Standards Institute 1304:family of routines, for spoiling the 1110:, primarily for booting Linux systems 866:Types and functions for manipulating 204:standard. Starting from the original 1800: 1439:called the ANSI C standard library. 1164:variants, and allows other forms of 1078:, a C standard library for embedded 2399:Miller, Todd C. and Theo de Raadt. 2011:"c99 - compile standard C programs" 810:type-generic mathematical functions 24: 2637: 1983: 1830:"The GNU C Library – Introduction" 1399:C (programming language) § History 1392: 1295:output, linear length calculation; 983: 25: 3249: 2666: 1372: 1021:interfaces to Microsoft Windows. 852:date- and time-handling functions 258:application programming interface 210:the C library POSIX specification 3205: 3204: 1619: – contains the 1361:routine is criticized for being 1287:string routines in general, for 1183: 963: 663:on data shared between threads. 628:For querying and specifying the 223:The C standard library provides 2604: 2582: 2564: 2546: 2521: 2503: 2478: 2460: 2442: 2424: 2406: 2393: 2375: 2350: 2332: 2307: 2289: 2271: 2246: 2228: 2203: 2185: 2160: 2135: 2114: 2102: 2078: 2054: 2029: 2003: 1777: 1761: 1683:and the main implementation of 1257:Buffer overflow vulnerabilities 735:core input and output functions 698:several useful types and macros 251: 1977: 1957: 1945: 1923: 1897: 1846: 1822: 1571: – defined in 887:wide-string-handling functions 13: 1: 2673:The C Library Reference Guide 2651:(1 ed.). Prentice Hall. 1794: 1476:implements functions such as 1427:became apparent. In 1983 the 1332:Except the extreme case with 1212:are available for linking if 1148:Some compilers (for example, 573:common mathematical functions 1424:AT&T's Bell Laboratories 1365:and otherwise vulnerable to 1270:string-manipulation routines 1219: 1104:GNU distribution for Windows 1057:Microsoft C run-time library 750:numeric conversion functions 7: 1742: 1498: 1339:The Practice of Programming 1168:(as the compiler knows the 1144:Compiler built-in functions 913:Three of the header files ( 10: 3254: 3118:Compatibility of C and C++ 2091:. open-std.org. 2008-08-10 2067:. open-std.org. 2007-03-28 1446: 1396: 1036:-derived operating systems 3200: 3184: 3131: 3108: 3045: 2964: 2895: 2847: 2838: 2792: 2749: 1726:, let alone the complete 1724:Standard Template Library 1014:Microsoft Visual C++ 792:string-handling functions 762:process control functions 717:exact-width integer types 613:signal-handling functions 498:exact-width integer types 3238:C (programming language) 1785:linear time complexities 1754: 1728:graphical user interface 1252:Problems and workarounds 523:variant character sets. 54:Character classification 3123:Comparison with Pascal 2743:C programming language 2649:The Standard C library 1636:are kept similar. The 1443:POSIX standard library 1422:and C were created at 1385:. A few functions set 1090:memory management unit 555:localization functions 200:, as specified in the 198:C programming language 2702:full C library source 1634:operational semantics 1310:format string attacks 769:<stdnoreturn.h> 107:Miscellaneous headers 1749:C++ Standard Library 1228:shall be defined to 1061:Microsoft Visual C++ 589:Declares the macros 281:Normative Addendum 1 239:, and several other 1965:"Compiling with cc" 1911:on 22 November 2008 1699:has a crate called 1470:regular expressions 1082:systems (MMU-less) 835:condition variables 680:a Boolean data type 652:<stdatomic.h> 3233:C standard library 2696:2015-12-23 at the 2691:C libraries manual 1437:software libraries 1240:, it shall define 621:<stdalign.h> 488:<inttypes.h> 307:) were added with 279:) were added with 186:C standard library 99:Alternative tokens 34:C standard library 3220: 3219: 2960: 2959: 2622:on 18 August 2016 2592:. Docs.python.org 2041:www.musl-libc.org 1984:Weimer, Florian. 1858:stackoverflow.com 1511:operating systems 1042:(glibc), used in 911: 910: 818:<threads.h> 758:memory allocation 670:<stdbool.h> 661:atomic operations 422:are also known). 388:for manipulating 376:<complex.h> 237:memory management 182: 181: 84:Memory allocation 69:File input/output 16:(Redirected from 3245: 3208: 3207: 2845: 2844: 2840:Standard library 2736: 2729: 2722: 2713: 2712: 2662: 2632: 2631: 2629: 2627: 2618:. Archived from 2608: 2602: 2601: 2599: 2597: 2586: 2580: 2579: 2568: 2562: 2561: 2550: 2544: 2543: 2541: 2539: 2525: 2519: 2518: 2507: 2501: 2500: 2498: 2497: 2482: 2476: 2475: 2464: 2458: 2457: 2446: 2440: 2439: 2428: 2422: 2421: 2410: 2404: 2397: 2391: 2390: 2379: 2373: 2372: 2370: 2369: 2354: 2348: 2347: 2336: 2330: 2329: 2327: 2326: 2311: 2305: 2304: 2293: 2287: 2286: 2275: 2269: 2268: 2266: 2265: 2250: 2244: 2243: 2232: 2226: 2225: 2223: 2222: 2207: 2201: 2200: 2189: 2183: 2182: 2180: 2179: 2164: 2158: 2157: 2155: 2154: 2139: 2133: 2132: 2130: 2128: 2118: 2112: 2111:- Stack overflow 2106: 2100: 2099: 2097: 2096: 2090: 2082: 2076: 2075: 2073: 2072: 2066: 2058: 2052: 2051: 2049: 2047: 2033: 2027: 2026: 2024: 2022: 2017:. The Open Group 2007: 2001: 2000: 1998: 1996: 1981: 1975: 1974: 1972: 1971: 1961: 1955: 1949: 1943: 1942: 1940: 1938: 1927: 1921: 1920: 1918: 1916: 1901: 1895: 1894: 1892: 1890: 1875: 1869: 1868: 1866: 1865: 1850: 1844: 1843: 1841: 1840: 1826: 1820: 1804: 1788: 1781: 1775: 1773: 1765: 1713:type conversions 1702: 1694: 1670: 1666: 1662: 1658: 1654: 1650: 1646: 1622: 1618: 1612: 1607: 1603: 1599: 1595: 1586: 1580: 1574: 1570: 1552: 1539: 1485: 1481: 1380: 1360: 1335: 1327: 1320: 1303: 1279: 1275: 1243: 1227: 1215: 1211: 1207: 1203: 1199: 1195: 975: 974:man 7 math_error 959: 951: 943: 937: 924: 920: 916: 905:set of functions 897: 895:<wctype.h> 879: 860: 845: 819: 802: 800:<tgmath.h> 785: 783:<string.h> 770: 743: 742:<stdlib.h> 728: 709: 707:<stdint.h> 691: 689:<stddef.h> 672: 653: 641: 639:<stdarg.h> 622: 606: 604:<signal.h> 596: 592: 584: 582:<setjmp.h> 566: 548: 547:<locale.h> 532: 530:<limits.h> 509: 507:<iso646.h> 490: 468: 455:for controlling 453:set of functions 445: 431: 408:set of functions 401: 386:set of functions 378: 356: 354:<assert.h> 338: 337: 330: 326: 322: 318: 314: 306: 302: 298: 294: 290: 286: 278: 274: 270: 241:operating system 194:standard library 174: 167: 160: 147: 138: 129: 120: 30: 29: 21: 3253: 3252: 3248: 3247: 3246: 3244: 3243: 3242: 3223: 3222: 3221: 3216: 3196: 3180: 3133: 3127: 3111:other languages 3110: 3109:Comparison with 3104: 3041: 2979:Borland Turbo C 2956: 2896:Implementations 2891: 2834: 2788: 2745: 2740: 2698:Wayback Machine 2669: 2659: 2640: 2638:Further reading 2635: 2625: 2623: 2610: 2609: 2605: 2595: 2593: 2588: 2587: 2583: 2570: 2569: 2565: 2552: 2551: 2547: 2537: 2535: 2533:Man.FreeBSD.org 2527: 2526: 2522: 2509: 2508: 2504: 2495: 2493: 2490:Man.freebsd.org 2484: 2483: 2479: 2466: 2465: 2461: 2448: 2447: 2443: 2430: 2429: 2425: 2412: 2411: 2407: 2398: 2394: 2381: 2380: 2376: 2367: 2365: 2362:Man.freebsd.org 2356: 2355: 2351: 2338: 2337: 2333: 2324: 2322: 2319:Man.freebsd.org 2313: 2312: 2308: 2295: 2294: 2290: 2277: 2276: 2272: 2263: 2261: 2258:Man.freebsd.org 2252: 2251: 2247: 2234: 2233: 2229: 2220: 2218: 2215:Man.freebsd.org 2209: 2208: 2204: 2191: 2190: 2186: 2177: 2175: 2172:Man.freebsd.org 2166: 2165: 2161: 2152: 2150: 2141: 2140: 2136: 2126: 2124: 2120: 2119: 2115: 2107: 2103: 2094: 2092: 2088: 2084: 2083: 2079: 2070: 2068: 2064: 2060: 2059: 2055: 2045: 2043: 2035: 2034: 2030: 2020: 2018: 2009: 2008: 2004: 1994: 1992: 1982: 1978: 1969: 1967: 1963: 1962: 1958: 1950: 1946: 1936: 1934: 1929: 1928: 1924: 1914: 1912: 1903: 1902: 1898: 1888: 1886: 1877: 1876: 1872: 1863: 1861: 1852: 1851: 1847: 1838: 1836: 1828: 1827: 1823: 1805: 1801: 1797: 1792: 1791: 1782: 1778: 1771: 1766: 1762: 1757: 1745: 1717:container types 1709: 1700: 1692: 1668: 1664: 1660: 1656: 1652: 1648: 1644: 1630: 1620: 1616: 1610: 1605: 1601: 1597: 1593: 1584: 1578: 1572: 1568: 1550: 1537: 1501: 1483: 1477: 1462:multi-threading 1451: 1449:C POSIX library 1445: 1401: 1395: 1393:Standardization 1378: 1375: 1367:race conditions 1355: 1352: 1333: 1322: 1315: 1306:execution stack 1298: 1293:null-terminated 1282:bounds checking 1277: 1273: 1263:buffer overflow 1259: 1254: 1242:__STDC_HOSTED__ 1241: 1226:__STDC_HOSTED__ 1225: 1222: 1213: 1209: 1205: 1201: 1197: 1193: 1186: 1146: 1128:, developed by 1018:redistributable 986: 984:Implementations 973: 966: 957: 949: 939: 933: 922: 918: 914: 893: 877:<wchar.h> 875: 859:<uchar.h> 858: 841: 817: 798: 781: 768: 741: 726:<stdio.h> 724: 705: 687: 668: 651: 637: 620: 602: 594: 590: 580: 562: 546: 539:macro constants 528: 505: 486: 475:macro constants 466:<float.h> 464: 441: 429:<errno.h> 427: 399:<ctype.h> 397: 390:complex numbers 374: 352: 328: 324: 320: 316: 312: 304: 300: 296: 292: 288: 284: 276: 272: 268: 254: 249: 178: 141: 132: 123: 114: 89:Process control 28: 23: 22: 15: 12: 11: 5: 3251: 3241: 3240: 3235: 3218: 3217: 3215: 3214: 3201: 3198: 3197: 3195: 3194: 3192:Dennis Ritchie 3188: 3186: 3182: 3181: 3179: 3178: 3173: 3168: 3163: 3158: 3153: 3148: 3143: 3137: 3135: 3129: 3128: 3126: 3125: 3120: 3114: 3112: 3106: 3105: 3103: 3102: 3097: 3092: 3087: 3082: 3077: 3072: 3067: 3062: 3057: 3051: 3049: 3043: 3042: 3040: 3039: 3034: 3021: 3016: 3011: 3006: 3001: 2996: 2991: 2986: 2981: 2976: 2970: 2968: 2962: 2961: 2958: 2957: 2955: 2954: 2949: 2944: 2939: 2934: 2929: 2928: 2927: 2917: 2912: 2911: 2910: 2899: 2897: 2893: 2892: 2890: 2889: 2884: 2879: 2874: 2869: 2867:Dynamic memory 2864: 2859: 2854: 2848: 2842: 2836: 2835: 2833: 2832: 2827: 2822: 2817: 2812: 2807: 2802: 2796: 2794: 2790: 2789: 2787: 2786: 2781: 2776: 2771: 2766: 2761: 2756: 2750: 2747: 2746: 2739: 2738: 2731: 2724: 2716: 2710: 2709: 2704: 2687: 2680: 2675: 2668: 2667:External links 2665: 2664: 2663: 2658:978-0131315099 2657: 2639: 2636: 2634: 2633: 2603: 2581: 2563: 2545: 2520: 2502: 2477: 2459: 2441: 2423: 2405: 2392: 2374: 2349: 2331: 2306: 2288: 2270: 2245: 2227: 2202: 2184: 2159: 2134: 2113: 2101: 2077: 2053: 2028: 2002: 1990:Stack Overflow 1976: 1956: 1944: 1922: 1896: 1883:C: C Standards 1870: 1845: 1821: 1798: 1796: 1793: 1790: 1789: 1776: 1759: 1758: 1756: 1753: 1752: 1751: 1744: 1741: 1736:.NET Framework 1708: 1705: 1629: 1626: 1625: 1624: 1614: 1608: 1591: 1582: 1576: 1566: 1548: 1542:red–black tree 1500: 1497: 1447:Main article: 1444: 1441: 1397:Main article: 1394: 1391: 1374: 1373:Error handling 1371: 1351: 1348: 1330: 1329: 1313: 1296: 1285: 1280:, for lack of 1258: 1255: 1253: 1250: 1221: 1218: 1185: 1182: 1145: 1142: 1141: 1140: 1123: 1117: 1111: 1105: 1095: 1094: 1093: 1073: 1067: 1054: 1037: 993:shared library 985: 982: 965: 962: 909: 908: 901: 898: 890: 889: 883: 880: 872: 871: 864: 861: 855: 854: 848: 846: 843:<time.h> 838: 837: 823: 820: 814: 813: 806: 803: 795: 794: 788: 786: 778: 777: 774: 771: 765: 764: 746: 744: 738: 737: 731: 729: 721: 720: 713: 710: 702: 701: 694: 692: 684: 683: 676: 673: 665: 664: 657: 654: 648: 647: 644: 642: 634: 633: 626: 623: 617: 616: 609: 607: 599: 598: 587: 585: 577: 576: 569: 567: 564:<math.h> 559: 558: 551: 549: 543: 542: 535: 533: 525: 524: 517:several macros 513: 510: 502: 501: 494: 491: 483: 482: 479:floating-point 471: 469: 461: 460: 457:floating-point 449: 446: 443:<fenv.h> 438: 437: 434: 432: 424: 423: 404: 402: 394: 393: 382: 379: 371: 370: 359: 357: 349: 348: 345: 342: 253: 250: 248: 245: 180: 179: 177: 176: 169: 162: 154: 151: 150: 149: 148: 139: 130: 121: 109: 108: 104: 103: 102: 101: 96: 91: 86: 81: 76: 71: 66: 61: 56: 51: 43: 42: 41:General topics 38: 37: 26: 9: 6: 4: 3: 2: 3250: 3239: 3236: 3234: 3231: 3230: 3228: 3213: 3212: 3203: 3202: 3199: 3193: 3190: 3189: 3187: 3183: 3177: 3174: 3172: 3169: 3167: 3164: 3162: 3159: 3157: 3154: 3152: 3149: 3147: 3144: 3142: 3139: 3138: 3136: 3130: 3124: 3121: 3119: 3116: 3115: 3113: 3107: 3101: 3098: 3096: 3095:Visual Studio 3093: 3091: 3088: 3086: 3085:GNOME Builder 3083: 3081: 3078: 3076: 3073: 3071: 3068: 3066: 3063: 3061: 3058: 3056: 3053: 3052: 3050: 3048: 3044: 3038: 3035: 3033: 3029: 3025: 3024:Visual Studio 3022: 3020: 3017: 3015: 3012: 3010: 3007: 3005: 3002: 3000: 2997: 2995: 2992: 2990: 2987: 2985: 2982: 2980: 2977: 2975: 2972: 2971: 2969: 2967: 2963: 2953: 2950: 2948: 2945: 2943: 2940: 2938: 2935: 2933: 2930: 2926: 2923: 2922: 2921: 2918: 2916: 2913: 2909: 2906: 2905: 2904: 2901: 2900: 2898: 2894: 2888: 2885: 2883: 2880: 2878: 2875: 2873: 2870: 2868: 2865: 2863: 2860: 2858: 2855: 2853: 2850: 2849: 2846: 2843: 2841: 2837: 2831: 2828: 2826: 2823: 2821: 2818: 2816: 2813: 2811: 2808: 2806: 2803: 2801: 2798: 2797: 2795: 2791: 2785: 2782: 2780: 2777: 2775: 2772: 2770: 2767: 2765: 2762: 2760: 2757: 2755: 2752: 2751: 2748: 2744: 2737: 2732: 2730: 2725: 2723: 2718: 2717: 2714: 2708: 2705: 2703: 2699: 2695: 2692: 2688: 2685: 2681: 2679: 2676: 2674: 2671: 2670: 2660: 2654: 2650: 2646: 2645:Plauger, P.J. 2642: 2641: 2621: 2617: 2613: 2607: 2591: 2585: 2577: 2573: 2567: 2559: 2555: 2549: 2534: 2530: 2524: 2516: 2512: 2506: 2491: 2487: 2481: 2473: 2469: 2463: 2455: 2451: 2445: 2437: 2433: 2427: 2419: 2415: 2409: 2402: 2396: 2388: 2384: 2378: 2363: 2359: 2353: 2345: 2341: 2335: 2320: 2316: 2310: 2302: 2298: 2292: 2284: 2280: 2274: 2259: 2255: 2249: 2241: 2237: 2231: 2216: 2212: 2206: 2198: 2194: 2188: 2173: 2169: 2163: 2148: 2144: 2138: 2123: 2117: 2110: 2105: 2087: 2081: 2063: 2057: 2042: 2038: 2032: 2016: 2012: 2006: 1991: 1987: 1980: 1966: 1960: 1953: 1948: 1933:. Etalabs.net 1932: 1926: 1910: 1906: 1900: 1884: 1880: 1879:"C Standards" 1874: 1859: 1855: 1849: 1835: 1831: 1825: 1819: 1817: 1812: 1808: 1803: 1799: 1786: 1780: 1769: 1764: 1760: 1750: 1747: 1746: 1740: 1737: 1733: 1729: 1725: 1722: 1718: 1714: 1704: 1698: 1690: 1686: 1682: 1678: 1674: 1643: 1639: 1635: 1615: 1609: 1592: 1590: 1583: 1577: 1567: 1564: 1560: 1556: 1549: 1547: 1543: 1536: 1535: 1534: 1532: 1528: 1524: 1520: 1516: 1512: 1509: 1505: 1496: 1494: 1489: 1486:, but before 1480: 1475: 1471: 1467: 1463: 1459: 1456:, as well as 1455: 1450: 1440: 1438: 1434: 1430: 1425: 1421: 1416: 1414: 1410: 1406: 1403:The original 1400: 1390: 1388: 1384: 1370: 1368: 1364: 1363:thread unsafe 1358: 1347: 1343: 1341: 1340: 1325: 1318: 1314: 1311: 1307: 1301: 1297: 1294: 1290: 1286: 1283: 1271: 1268: 1267: 1266: 1264: 1249: 1247: 1239: 1235: 1231: 1217: 1191: 1184:Linking, libm 1181: 1177: 1175: 1171: 1167: 1163: 1159: 1158:shared object 1155: 1151: 1139: 1135: 1131: 1130:Keith Packard 1127: 1124: 1121: 1118: 1115: 1112: 1109: 1106: 1103: 1099: 1096: 1092:(MMU) support 1091: 1087: 1084: 1083: 1081: 1077: 1074: 1071: 1068: 1065: 1062: 1058: 1055: 1053: 1049: 1045: 1041: 1040:GNU C Library 1038: 1035: 1031: 1027: 1026: 1025: 1022: 1019: 1015: 1011: 1006: 1003: 999: 994: 990: 981: 979: 971: 964:Documentation 961: 955: 947: 946:GNU C Library 942: 936: 931: 926: 906: 902: 899: 896: 892: 891: 888: 884: 881: 878: 874: 873: 869: 865: 862: 857: 856: 853: 849: 847: 844: 840: 839: 836: 832: 828: 824: 821: 816: 815: 811: 807: 804: 801: 797: 796: 793: 789: 787: 784: 780: 779: 775: 772: 767: 766: 763: 759: 755: 751: 747: 745: 740: 739: 736: 732: 730: 727: 723: 722: 718: 714: 711: 708: 704: 703: 699: 695: 693: 690: 686: 685: 681: 677: 674: 671: 667: 666: 662: 658: 655: 650: 649: 645: 643: 640: 636: 635: 631: 627: 624: 619: 618: 614: 610: 608: 605: 601: 600: 588: 586: 583: 579: 578: 574: 570: 568: 565: 561: 560: 556: 552: 550: 545: 544: 540: 536: 534: 531: 527: 526: 522: 518: 514: 511: 508: 504: 503: 499: 495: 492: 489: 485: 484: 480: 476: 472: 470: 467: 463: 462: 459:environment. 458: 454: 450: 447: 444: 440: 439: 435: 433: 430: 426: 425: 421: 417: 413: 412:character set 409: 405: 403: 400: 396: 395: 391: 387: 383: 380: 377: 373: 372: 368: 364: 361:Declares the 360: 358: 355: 351: 350: 346: 343: 340: 339: 336: 334: 321:stdnoreturn.h 310: 282: 265: 263: 259: 244: 242: 238: 234: 230: 226: 221: 219: 218:ISO C library 215: 211: 207: 203: 199: 195: 191: 187: 175: 170: 168: 163: 161: 156: 155: 153: 152: 145: 140: 136: 131: 127: 122: 118: 113: 112: 111: 110: 106: 105: 100: 97: 95: 92: 90: 87: 85: 82: 80: 77: 75: 72: 70: 67: 65: 62: 60: 57: 55: 52: 50: 47: 46: 45: 44: 40: 39: 35: 32: 31: 19: 3209: 3065:Code::Blocks 3037:Watcom C/C++ 2839: 2825:Preprocessor 2805:Header files 2648: 2624:. Retrieved 2620:the original 2615: 2606: 2594:. Retrieved 2584: 2575: 2566: 2557: 2548: 2538:14 September 2536:. Retrieved 2532: 2523: 2514: 2505: 2494:. Retrieved 2492:. 2012-03-29 2489: 2480: 2471: 2462: 2453: 2444: 2435: 2426: 2417: 2408: 2395: 2386: 2377: 2366:. Retrieved 2364:. 2010-09-10 2361: 2352: 2343: 2334: 2323:. Retrieved 2321:. 2012-03-18 2318: 2309: 2300: 2291: 2282: 2273: 2262:. Retrieved 2260:. 1994-04-19 2257: 2248: 2239: 2230: 2219:. Retrieved 2217:. 2011-05-13 2214: 2205: 2196: 2187: 2176:. Retrieved 2174:. 2007-12-27 2171: 2162: 2151:. Retrieved 2149:. 2008-08-11 2146: 2137: 2125:. Retrieved 2116: 2104: 2093:. Retrieved 2080: 2069:. Retrieved 2056: 2044:. Retrieved 2040: 2031: 2019:. Retrieved 2014: 2005: 1993:. Retrieved 1989: 1979: 1968:. Retrieved 1959: 1954:, GCC Manual 1947: 1935:. Retrieved 1925: 1913:. Retrieved 1909:the original 1899: 1887:. Retrieved 1882: 1873: 1862:. Retrieved 1857: 1848: 1837:. Retrieved 1833: 1824: 1814: 1802: 1779: 1763: 1710: 1631: 1503: 1502: 1452: 1417: 1402: 1386: 1382: 1376: 1353: 1344: 1337: 1331: 1289:side-effects 1272:, including 1260: 1245: 1238:freestanding 1237: 1234:freestanding 1233: 1229: 1223: 1187: 1178: 1174:instrumented 1170:control-flow 1166:optimization 1147: 1048:GNU/kFreeBSD 1023: 1017: 1007: 1001: 987: 967: 927: 912: 632:of objects. 347:Description 280: 266: 262:header files 255: 252:Header files 222: 217: 189: 185: 183: 79:Localization 33: 3156:Objective-C 2937:Windows CRT 2616:Rust Crates 2046:24 February 2021:24 February 1995:24 February 1931:"musl libc" 1889:24 November 1768:Morris worm 1719:" like the 1649:std::printf 1589:Berkeley DB 1555:Linked list 1551:sys/queue.h 1495:C library. 1176:variants). 1154:object file 1005:libraries. 919:stdatomic.h 870:characters 414:(typically 369:a program. 317:stdatomic.h 64:Mathematics 3227:Categories 3132:Descendant 3004:Norcroft C 2830:Data types 2779:Embedded C 2682:Microsoft 2596:28 October 2496:2013-08-25 2368:2013-08-25 2325:2013-08-25 2264:2013-08-25 2221:2013-08-25 2178:2013-08-25 2153:2014-03-13 2127:28 October 2095:2014-03-13 2071:2014-03-13 2037:"musl FAQ" 1970:2013-03-02 1937:28 October 1915:28 October 1864:2015-03-04 1839:2013-12-05 1795:References 1563:tail queue 1546:splay tree 1538:sys/tree.h 1466:networking 1405:C language 1379:math_error 1059:, part of 960:function. 958:va_count() 451:Defines a 384:Defines a 313:stdalign.h 293:inttypes.h 243:services. 49:Data types 3134:languages 2966:Compilers 2908:libhybris 2810:Operators 2800:Functions 1687:known as 1657:std::feof 1653:std::atoi 1642:namespace 1606:strncpy() 1602:strncat() 1598:strlcpy() 1594:strlcat() 1220:Detection 1206:complex.h 1086:uclibc-ng 989:Unix-like 970:man pages 923:threads.h 915:complex.h 630:alignment 481:library. 367:debugging 325:threads.h 297:stdbool.h 285:complex.h 74:Date/time 3211:Category 3185:Designer 3100:NetBeans 3090:KDevelop 3070:CodeLite 2915:dietlibc 2882:Variadic 2857:File I/O 2793:Features 2694:Archived 2647:(1992). 2529:"vis(3)" 2254:"fgetln" 2147:man7.org 1813:(2018). 1743:See also 1734:and the 1569:fgetln() 1513:such as 1504:BSD libc 1499:BSD libc 1357:strerror 1278:strcat() 1274:strcpy() 1138:AVR Libc 1126:picolibc 1070:dietlibc 1044:GNU Hurd 1030:BSD libc 1002:de facto 956:has the 950:alloca.h 941:unistd.h 903:Defines 885:Defines 850:Defines 808:Defines 790:Defines 748:Defines 733:Defines 715:Defines 696:Defines 678:Defines 611:Defines 571:Defines 553:Defines 537:Defines 515:Defines 496:Defines 473:Defines 406:Defines 305:tgmath.h 301:stdint.h 277:wctype.h 269:iso646.h 196:for the 144:stdarg.h 135:setjmp.h 117:assert.h 18:Stdlib.h 3075:Eclipse 3028:Express 2784:MISRA C 2689:NetBSD 2686:on MSDN 2626:31 July 2211:"queue" 1834:gnu.org 1689:CPython 1669:cstdlib 1647:(e.g., 1573:stdio.h 1523:OpenBSD 1515:FreeBSD 1484:libc.so 1482:within 1413:Fortran 1080:μClinux 954:OpenVMS 935:fcntl.h 868:Unicode 831:mutexes 827:threads 595:longjmp 521:ISO 646 331:) with 329:uchar.h 273:wchar.h 192:is the 126:errno.h 94:Signals 59:Strings 3055:Anjuta 2952:uClibc 2947:Newlib 2925:EGLIBC 2903:Bionic 2872:String 2820:Syntax 2815:String 2754:ANSI C 2655:  2612:"libc" 2576:bxr.su 2558:bxr.su 2515:bxr.su 2472:bxr.su 2454:bxr.su 2436:bxr.su 2418:bxr.su 2387:bxr.su 2344:bxr.su 2301:bxr.su 2283:bxr.su 2240:bxr.su 2197:bxr.su 2168:"tree" 1885:. Keil 1860:. 2012 1772:gets() 1685:Python 1661:cstdio 1565:, etc. 1559:queues 1531:4.4BSD 1519:NetBSD 1468:, and 1433:ANSI C 1334:gets() 1300:printf 1210:fenv.h 1208:, and 1202:math.h 1162:inline 1134:Newlib 1120:Bionic 1102:Cygwin 1098:Newlib 1076:μClibc 952:, and 921:, and 591:setjmp 420:EBCDIC 363:assert 327:, and 303:, and 289:fenv.h 275:, and 233:string 225:macros 206:ANSI C 36:(libc) 3166:Limbo 3080:Geany 3060:CLion 2984:Clang 2932:klibc 2920:glibc 2887:POSIX 2486:"err" 2315:"fts" 2089:(PDF) 2065:(PDF) 1755:Notes 1693:stdio 1665:cmath 1621:vis() 1617:vis.h 1611:err.h 1579:fts.h 1527:macOS 1474:glibc 1454:POSIX 1418:Both 1409:COBOL 1387:errno 1383:errno 1324:scanf 1108:klibc 1052:Linux 998:POSIX 978:Linux 930:POSIX 416:ASCII 202:ISO C 3176:Vala 3161:Alef 3047:IDEs 3014:SDCC 2942:musl 2877:Time 2862:Math 2852:Char 2700:and 2653:ISBN 2628:2016 2598:2011 2540:2013 2358:"db" 2129:2011 2048:2021 2023:2021 1997:2021 1939:2011 1917:2011 1891:2011 1732:Java 1701:libc 1697:Rust 1681:Ruby 1677:Perl 1604:and 1596:and 1585:db.h 1544:and 1525:and 1488:NPTL 1479:fork 1420:Unix 1411:and 1354:The 1321:and 1317:gets 1276:and 1190:libm 1136:and 1114:musl 1050:and 1028:The 1010:DLLs 948:has 938:and 928:The 833:and 659:For 593:and 344:From 341:Name 256:The 229:type 190:libc 184:The 146:> 142:< 137:> 133:< 128:> 124:< 119:> 115:< 3141:C++ 3032:C++ 3019:TCC 3009:PCC 2999:LCC 2994:ICC 2989:GCC 2974:ACK 2774:C23 2769:C17 2764:C11 2759:C99 1811:IEC 1807:ISO 1721:C++ 1645:std 1638:C++ 1508:BSD 1493:ISO 1458:SUS 1244:to 1214:-lm 1198:-lm 1194:-lm 1150:GCC 1034:BSD 980:). 976:in 900:NA1 882:NA1 863:C11 822:C11 805:C99 773:C11 712:C99 675:C99 656:C11 625:C11 512:NA1 493:C99 448:C99 381:C99 333:C11 309:C99 188:or 3229:: 3171:Go 3146:C# 3030:, 3026:, 2614:. 2574:. 2556:. 2531:. 2513:. 2488:. 2470:. 2452:. 2434:. 2416:. 2385:. 2360:. 2342:. 2317:. 2299:. 2281:. 2256:. 2238:. 2213:. 2195:. 2170:. 2145:. 2039:. 2013:. 1988:. 1881:. 1856:. 1832:. 1818:§7 1679:, 1675:, 1667:, 1663:, 1655:, 1651:, 1561:, 1557:, 1521:, 1517:, 1464:, 1369:. 1359:() 1326:() 1319:() 1302:() 1248:. 1204:, 1046:, 917:, 829:, 812:. 760:, 756:, 752:, 719:. 700:. 682:. 615:. 575:. 557:. 500:. 392:. 323:, 319:, 315:, 299:, 295:, 291:, 287:, 271:, 227:, 220:. 3151:D 2735:e 2728:t 2721:v 2661:. 2630:. 2600:. 2578:. 2560:. 2542:. 2517:. 2499:. 2474:. 2456:. 2438:. 2420:. 2389:. 2371:. 2346:. 2328:. 2303:. 2285:. 2267:. 2242:. 2224:. 2199:. 2181:. 2156:. 2131:. 2098:. 2074:. 2050:. 2025:. 1999:. 1973:. 1941:. 1919:. 1893:. 1867:. 1842:. 1809:/ 1673:D 1312:; 1246:0 1230:1 1066:. 173:e 166:t 159:v 20:)

Index

Stdlib.h
C standard library
Data types
Character classification
Strings
Mathematics
File input/output
Date/time
Localization
Memory allocation
Process control
Signals
Alternative tokens
assert.h
errno.h
setjmp.h
stdarg.h
v
t
e
standard library
C programming language
ISO C
ANSI C
the C library POSIX specification
International Organization for Standardization
macros
type
string
memory management

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.