Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
C (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Libraries == The C programming language uses [[Library (computing)|libraries]] as its primary method of extension. In C, a library is a set of functions contained within a single "archive" file. Each library typically has a [[header file]], which contains the prototypes of the functions contained within the library that may be used by a program, and declarations of special data types and macro symbols used with these functions. For a program to use a library, it must include the library's header file, and the library must be linked with the program, which in many cases requires [[compiler flag]]s (e.g., <code>-lm</code>, shorthand for "link the math library").<ref name="bk21st" /> The most common C library is the [[C standard library]], which is specified by the [[ISO standard|ISO]] and [[ANSI C]] standards and comes with every C implementation (implementations which target limited environments such as [[embedded system]]s may provide only a subset of the standard library). This library supports stream input and output, memory allocation, mathematics, character strings, and time values. Several separate standard headers (for example, <code>stdio.h</code>) specify the interfaces for these and other standard library facilities. Another common set of C library functions are those used by applications specifically targeted for [[Unix]] and [[Unix-like]] systems, especially functions which provide an interface to the [[Kernel (operating system)|kernel]]. These functions are detailed in various standards such as [[POSIX]] and the [[Single UNIX Specification]]. Since many programs have been written in C, there are a wide variety of other libraries available. Libraries are often written in C because C compilers generate efficient [[object code]]; programmers then create interfaces to the library so that the routines can be used from higher-level languages like [[Java (programming language)|Java]], [[Perl]], and [[Python (programming language)|Python]].<ref name="bk21st" /> === File handling and streams === File input and output (I/O) is not part of the C language itself but instead is handled by libraries (such as the C standard library) and their associated header files (e.g. <code>stdio.h</code>). File handling is generally implemented through high-level I/O which works through [[Stream (computing)|streams]]. A stream is from this perspective a data flow that is independent of devices, while a file is a concrete device. The high-level I/O is done through the association of a stream to a file. In the C standard library, a [[data buffer|buffer]] (a memory area or queue) is temporarily used to store data before it is sent to the final destination. This reduces the time spent waiting for slower devices, for example a [[hard drive]] or [[solid-state drive]]. Low-level I/O functions are not part of the standard C library{{clarify|date=October 2021}} but are generally part of "bare metal" programming (programming that is independent of any [[operating system]] such as most [[embedded programming]]). With few exceptions, implementations include low-level I/O.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)