Getting started with C

suggest change

Language versions

Version Publication
C89 ANSI X3.159-1989
C90 ISO/IEC 9899:1990
C95 ISO/IEC 9899:1990/Amd 1:1995
C99 ISO/IEC 9899:1999
C11 ISO/IEC 9899:2011
C17 ISO/IEC 9899:2018
C23 ISO/IEC 9899:2024

K&R C refers to the language described by Kernighan and Ritchie before standardization; it is not a formal standard version. C23 is the current published standard. Projects often target an older version because of compiler, library, operating-system, or embedded-platform requirements.

The language

C is a general-purpose, statically typed programming language that supports procedural and structured programming, lexical scope, and recursion. It provides low-level facilities that map efficiently to common machine operations while retaining enough abstraction for portable programs.

Dennis Ritchie developed C at Bell Labs in the early 1970s, where it was used to reimplement much of Unix. C is now used for operating systems, embedded software, language runtimes, libraries, command-line tools, and performance-sensitive application code.

Portable C depends on more than syntactically valid source. A program must also avoid undefined behavior, account for implementation-defined properties, and restrict itself to APIs available in its target environment.

Compilers and language modes

Common C implementations include:

Compiler support is not all-or-nothing. A compiler front end may implement a language feature while the accompanying C library lacks the corresponding header or function. Consult the implementation's current documentation for its supported standards and known limitations.

Compilers also provide nonstandard extensions. Extensions can be useful, but they reduce portability unless every target implementation supports them. GCC and Clang accept options such as -std=c23 and -pedantic to select a language version and diagnose many extensions. Other compilers use different options.

Choose the newest language version supported by every required target, then enable a strong warning set. Treat warnings as issues to investigate; do not assume that a warning-free program is correct.

Style

Whitespace usually does not change the meaning of C source, but consistent formatting makes control flow, ownership, and lifetime easier to review. Follow the established style of the project. Be consistent about indentation, brace placement, naming, and spaces around operators.

Style is separate from correctness. Formatting cannot make an out-of-bounds access, an invalid lifetime, or a data race safe.

Standard C and platform APIs

The C standard library does not define every facility needed by a real application. Threads, networking, processes, filesystems, and signals may also involve platform APIs such as POSIX or Windows. State clearly when an example relies on a platform-specific interface instead of ISO C.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents