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!
== Overview == [[File:Ken n dennis.jpg|thumb|[[Dennis Ritchie]] (right), the inventor of the C programming language, with [[Ken Thompson]]]] C is an [[Imperative programming|imperative]], procedural language in the [[ALGOL]] tradition. It has a static [[type system]]. In C, all [[executable code]] is contained within [[subroutine]]s (also called "functions", though not in the sense of [[functional programming]]). [[Function parameter]]s are passed by value, although [[Array (data type)|arrays]] are passed as [[Pointer (computer programming)|pointers]], i.e. the address of the first item in the array. ''Pass-by-reference'' is simulated in C by explicitly passing pointers to the thing being referenced. C program source text is [[Free-form language|free-form]] code. [[Semicolon]]s terminate [[Statement (programming)|statements]], while [[curly braces]] are used to group statements into [[Block (programming)|blocks]]. The C language also exhibits the following characteristics: * The language has a small, fixed number of keywords, including a full set of [[control flow]] primitives: <code>[[Conditional (computer programming)|if/else]]</code>, <code>[[For loop|for]]</code>, <code>[[Do while loop|do/while]]</code>, <code>[[While loop|while]]</code>, and <code>[[Switch statement|switch]]</code>. User-defined names are not distinguished from keywords by any kind of [[Sigil (computer programming)|sigil]]. * It has a large number of arithmetic, [[bitwise]], and logic operators: {{codes|+|+{{=}}|++|&|{{!!}}|d=,}}, etc. * More than one [[Assignment (computer science)|assignment]] may be performed in a single statement. * Functions: ** Function return values can be ignored, when not needed. ** Function and data pointers permit ''ad hoc'' [[run-time polymorphism]]. ** Functions may not be defined within the lexical scope of other functions. ** Variables may be defined within a function, with [[lexical variable scope|scope]]. ** A function may call itself, so [[Recursion (computer science)|recursion]] is supported. * Data typing is [[Static typing|static]], but [[Strong and weak typing|weakly enforced]]; all data has a type, but [[implicit conversion]]s are possible. * User-defined ([[typedef]]) and compound types are possible. ** Heterogeneous aggregate data types (<code>[[Struct (C programming language)|struct]]</code>) allow related data elements to be accessed and assigned as a unit. The contents of whole structs cannot be compared using a single built-in operator (the elements must be compared individually). ** [[Union type|Union]] is a structure with overlapping members; it allows multiple data types to share the same memory location. ** [[Array (data type)|Array]] indexing is a secondary notation, defined in terms of pointer arithmetic. Whole arrays cannot be assigned or compared using a single built-in operator. There is no "array" keyword in use or definition; instead, square brackets indicate arrays syntactically, for example <code>month[11]</code>. ** [[Enumerated type]]s are possible with the <code>enum</code> keyword. They are freely interconvertible with integers. ** [[String (computer science)|Strings]] are not a distinct data type, but are conventionally [[C string handling|implemented]] as [[Null-terminated string|null-terminated]] character arrays. * Low-level access to [[computer memory]] is possible by converting machine addresses to [[Pointer (computer programming)|pointers]]. * [[Procedure (computer science)|Procedures]] (subroutines not returning values) are a special case of function, with an empty return type <code>void</code>. * Memory can be [[Dynamic allocation|allocated]] to a program with calls to [[library routine]]s. * A [[C preprocessor|preprocessor]] performs [[Macro (computer science)|macro]] definition, [[source code]] file inclusion, and [[conditional compilation]]. * There is a basic form of [[Modular programming|modularity]]: files can be compiled separately and [[Linker (computing)|linked]] together, with control over which functions and data objects are visible to other files via [[Static (keyword)|<code>static</code>]] and <code>extern</code> attributes. * Complex functionality such as [[Input/output|I/O]], [[String (computer science)|string]] manipulation, and mathematical functions are consistently delegated to [[library routine]]s. * The generated code after compilation has relatively straightforward needs on the underlying platform, which makes it suitable for creating operating systems and for use in [[embedded system]]s. While C does not include certain features found in other languages (such as [[Object-oriented programming|object orientation]] and [[garbage collection (computer science)|garbage collection]]), these can be implemented or emulated, often through the use of external libraries (e.g., the [[GLib Object System]] or the [[Boehm garbage collector]]). === Relations to other languages === {{main|List of C-family programming languages}} Many later languages have borrowed directly or indirectly from C, including [[C++]], [[C Sharp (programming language)|C#]], Unix's [[C shell]], [[D (programming language)|D]], [[Go (programming language)|Go]], [[Java (programming language)|Java]], [[JavaScript]] (including [[JavaScript#transpilers|transpilers]]), [[Julia (programming language)|Julia]], [[Limbo (programming language)|Limbo]], [[LPC (programming language)|LPC]], [[Objective-C]], [[Perl]], [[PHP]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[Rust (programming language)|Rust]], [[Swift (programming language)|Swift]], [[Verilog]] and [[SystemVerilog]] (hardware description languages).<ref name="vinsp" /> These languages have drawn many of their [[control structures]] and other basic features from C. Most of them also express highly similar [[Syntax (programming languages)|syntax]] to C, and they tend to combine the recognizable expression and statement [[C syntax|syntax of C]] with underlying type systems, [[data model]]s, and semantics that can be radically different.
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)