Namespaces
Variants
Views
Actions

C language

From cppreference.com
< c
Revision as of 10:13, 20 January 2013 by Nate (Talk | contribs)

This is a brief reference of available C constructs.

Contents

General topics

Preprocessor

Comments

Keywords

ASCII chart

Escape sequences

History of C

Flow control

Conditional execution statements

Different code paths are executed according to the value of given expression

  • if executes code conditionally
  • switch executes code according to the value of an integral argument

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

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

Functions

The same code can be reused at different locations in the program

Types

Specifiers

Literals

Literals are the tokens of a C program that represent constant values, embedded in the source code.

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 specified 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 += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b

++a
--a
a++
a--

+a
-a
a + b
a - b
a * b
a / b
a % b
~a
a & b
a | b
a ^ b
a << b
a >> b

!a
a && b
a || b

a == b
a != b
a < b
a > b
a <= b
a >= b

a[b]
*a
&a
a->b
a.b

a(...)
a, b
(type) a
? :
sizeof
_Alignof
(since C11)

Utilities

Types
Casts

Miscellaneous