C language
This is a brief reference of available C constructs.
Contents |
[edit] General topics
[edit] Preprocessor
[edit] Comments
[edit] Keywords
[edit] ASCII chart
[edit] Escape sequences
[edit] History of C
[edit] Flow control
[edit] Conditional execution statements
Different code paths are executed according to the value of given expression
[edit] Iteration statements
The same code is executed several times
- for executes loop
- while executes loop, checking condition before each iteration
- do-while executes loop, checking condition after each iteration
[edit] Jump statements
Continue execution at a different location
- continue skips the remaining part of the enclosing loop body
- break terminates the enclosing loop
- goto continues execution in another location
- return terminates execution of the enclosing function
[edit] Functions
The same code can be reused at different locations in the program
- function declaration declares a function
- inline specifier hints the compiler to insert a function's body directly into the calling code
[edit] Concepts
[edit] Scopes of identifiers
Scope determines the visibility of an identifier.
[edit] Linkages of identifiers
Linkage determines the accessibility of an identifier.
[edit] Name spaces of identifiers
Name spaces group identifiers around a particular purpose.
[edit] Storage durations of objects
Storage duration determines the lifetime of an object.
- Static storage duration
- Thread storage duration
- Automatic storage duration
- Allocated storage duration
[edit] Types
Type determines the interpretation of a value.
- basic types define character, integer and floating point types
- array type, contiguously allocated nonempty set of objects with a particular member object type,
- structure type, a sequentially allocated nonempty set of member objects
- union type defines types that can hold data in several representations
- function type defines function call signatures, that is the types of arguments and the return type
- pointer type, holding a memory location
- atomic type, designated by the construct _Atomic
- enumeration type defines types that are able to hold only one of the specified values
[edit] Representations of types
[edit] Compatible type and composite type
[edit] Alignment of objects
Data alignment can affect performance.
[edit] Conversions
Conversions, implicitly or explicitly, change the value of one data type into a value of another data type.
[edit] Arithmetic operands
- Integer conversion rank
- Boolean type
- Signed and unsigned integers
- Real floating and integer
- Real floating types
- Complex types
- Real and complex
- Usual arithmetic conversions
[edit] Other operands
[edit] Declarations
A declaration specifies the interpretation and attributes of a set of identifiers.
[edit] Specifiers
- storage-class specifiers specifies storage duration and linkage of a type
- type specifiers specifies the type of a declaration
- function specifiers specifies how the compiler should handle a function (since C99)
- alignment specifier specifies that the storage for the variable should be aligned by specific amount (since C99)
[edit] Type Qualifiers
- const type qualifier specifies an object whose value cannot be changed
- volatile type qualifier specifies an object whose value can be change by ways outside the control of the compiler
- restrict type qualifier
- _Atomic type qualifier
[edit] Initializers
An initializer specifies the initial value stored in an object.
- default initialization
- arithmetic-type initialization
- pointer-type initialization
- array-type initialization
- struct-type initialization
- union-type initialization
[edit] Literals
Literals are the tokens of a C program that represent constant values, embedded in the source code.
- integer literals are decimal, octal, or hexadecimal numbers of integer type.
- character literals are individual characters of type char, char16_t, char32_t, or wchar_t.
- floating-point literals are values of type float, double, or long double
- string literals are sequences of characters, which may be narrow, multibyte, or wide.
- boolean literals are values of type bool, that is true and false (since C99)
- user-defined literals are constant values of user-specified type (since C99)
[edit] Expressions
An expression is a sequence of operators and operands that specifies a computation. An expression can result in a value and can cause side effects.
- order of evaluation of arguments and subexpressions specifies the order in which intermediate results are obtained.
- operators allow the use of syntax commonly found in mathematics
Common operators | ||||||
---|---|---|---|---|---|---|
assignment | increment decrement |
arithmetic | logical | comparison | member access |
other |
a = b |
++a |
+a |
!a |
a == b |
a[b] |
a(...) |
- operator precedence is the order in which operators are bound to their arguments
- alternative representations exist for some of the operators
[edit] Utilities
- Types
- typedef declaration creates a synonym for a type
- attributes defines additional information about variable (since C99)
- Casts
- standard conversions implicit conversions from one type to another
[edit] Miscellaneous
[edit] See also
C++ documentation for C++ language constructs
|