116 of 146
added 806 characters in body
zwol
  • 133.6k
  • 36
  • 244
  • 354

C (pronounced "See", like the letter C) is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the UNIX operating system. Its design provides constructs that map efficiently to typical machine instructions, and therefore it found lasting use in applications that had formerly been coded in assembly language. It is a highly efficient procedural programming language and has an emphasis on functions whereas modern object-oriented programming languages tend to emphasize data.

The C programming language was based on the earlier programming languages B, BCPL, and CPL.

The C language and its optional library are standardized as ISO/IEC 9899, the current version being ISO/IEC 9899:2018 (C17). A draft version N2176 is available for free.

Although C was designed for implementing system software, it is also widely used for developing portable application software.

C is one of the most widely used programming languages of all time and there are very few computer architectures for which a C compiler does not exist. C has greatly influenced many other popular programming languages, most notably C++, which began as an extension to C. Other languages that have been greatly influenced by C are C#, Objective-C, and Java.


##Design C is an imperative (procedural) systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was, therefore, useful for many applications that had formerly been coded in assembly language.

Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with very few changes to its source code. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers.


## Tag usage

When posting questions about C programming, please keep in mind that C compilers are slow to fully adopt new revisions of the C standard, and many C codebases in common use are still written against old revisions. Therefore, we assume you are asking about the oldest standardized version of the language (ISO 9899:1990, usually abbreviated "C89" for complicated historical reasons) unless you specifically mention you are working with a newer version. Please also keep this in mind when answering or commenting on questions tagged .

Many C compilers' default behavior was tuned for code written a long time ago, to much looser tolerances than are now considered the minimum; if you are writing new C code, we strongly encourage you to turn on lots of optional "warnings" and treat them all as must-fix. With the widely used GCC and Clang, for example, a good tradeoff among standards conformance, bug detection, and real-world compatibility is -std=gnuxx -Wall -Wextra -Wpedantic on the command line (where the xx in -std=gnuxx is a placeholder for the revision of the standard you want, for example -std=gnu11 for the 2011 revision). The stricter -std=cxx modes are likely to expose bugs in system headers, so they should only be used if you are prepared to deal with that possibility.

Please make sure to include:

  • Target system & compiler version
  • Add , , , or in case your question is specific to one particular version of the standard (more info).
  • Relevant flags/switches passed to the compiler, assembler or linker if applicable
  • Verbatim copies of compiler warnings or errors if applicable. Please post them as text and not as screen shots.
  • Whenever asking for debugging help, a complete but minimal program demonstrating the bug, that we can experiment with. Bugs in C code often have their root cause nowhere near the place flagged by the compiler or debugger as erroneous; if you only show us a fragment of your program, there's a good chance we won't be able to help.

###Is it C, C++ or both?

This tag is for questions related to C, not C++. In some cases, you may be working with both and applying both tags is entirely appropriate. However, please refrain from using both tags in an effort to help your question reach a wider audience. After all, C++ answers won't help you solve the problem in C, and good C answers rarely describe the best approach in C++.


##Frequently Asked Questions (FAQ)

Types and qualifiers

Declaration and initialization

Scope and storage duration

Integer arithmetic

Floating point arithmetic

Operators, precedence and order of evaluation

Arrays

Pointers and null

Function pointers

Strings

Dynamic memory allocation

Structs and unions

The pre-processor and macros

Standard compliance

Undefined, unspecified and implementation-defined behavior

The standard library

Best practices and style concerns


###External resources


Hello World program in C

#include <stdio.h>

int main(void)
{
    printf("hello, world\n");
    return 0;
}

Chat Room

Chat about C with other Stack Overflow users


C Online IDE

Run C online