C (programming language)
The C programming language is a computer programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie at Bell Labs. They used it to improve the UNIX operating system. It is still much used today. C is a procedural language, which means that people write their programs as a series of step-by-step instructions. C is a compiled language, which means that the computer source code, written in C, is converted to make some machine code that a computer chip can actually execute.
Because the ideas behind C are like the ideas used in the design of the computer, the compiler (program builder) can generate fast machine code for the computer. The language itself has very few keywords, and most things are done using libraries, which are collections of code made to be reused. C has a big standard library called stdio, which stands for standard input/output.
C has a variety of uses:
- writing embedded systems like the code that runs inside a computer mouse, or a car headlight.
- writing device drivers like the code inside a laptop computer that interacts with the touchpad or the microphone
- writing protocol stacks like the code that allows one computer to talk to other computers on the internet.
- writing operating systems, such as the Linux kernel, MacOS and UNIX, and the utilities that come with those operating systems.
- writing application software, such as web browsers, word processors, etc.
- writing video games. Many of the most well-reviewed video games, including Doom, Quake, and Super Mario 64 are written in C.
- The compilers and interpreters of many other programming languages, such as Python and Perl, are written in C.
C standards
There are three successive standards for the C programming Archived 2021-06-04 at the Wayback Machine language ANSI C, ISO C and Standard C which are published by the American National Standards Institute (ANSI) and the International Organization for Standardization (ISO).
C is available for many different types of computers. This is why C is called a "portable" language. A program that is written in C and that respects certain limitations can be compiled for most platforms, and all in mainstream use.
The syntax of C has also influenced many other programming languages, such as C++, C#, and Java, and many more programming languages we use nowadays.
Example code
Here is an example of a program written in C. When built and run it will show "Hello world!", followed by a new line on the computer screen.
<syntaxhighlight lang="c">
- include <stdio.h>
int main() {
puts("Hello world!"); return 0;
} </syntaxhighlight>
- <syntaxhighlight lang="c" inline>#include <stdio.h></syntaxhighlight> gets the standard input/output tools ready for the program to use. This allows text to be displayed (output).
- <syntaxhighlight lang="c" inline>int main()</syntaxhighlight> is called the main function, and it is where the first code starts being run in a C program.
- <syntaxhighlight lang="c" inline="">puts("Hello world!\n");</syntaxhighlight> is what displays text, in this case, "Hello world!".
- <syntaxhighlight lang="c" inline>return 0;</syntaxhighlight> tells the computer that the program finished and did not run into problems.
C (programming Language) Media
Dennis Ritchie (right), the inventor of the C programming language, with Ken Thompson
The cover of the book The C Programming Language, first edition, by Brian Kernighan and Dennis Ritchie
"Hello, World!" program by Brian Kernighan (1978)
The TIOBE index*graph, showing a comparison of the popularity of various programming languages
Related pages
Other websites
- Introduction to C programming
- Coding Programmer Page / C Library Reference and Examples (English)
- C (programming language) -Citizendium