In C, some expressions yield undefined behavior. The standard explicitly chooses to not define how a compiler should behave if it encounters such an expression. As a result, a compiler is free to do whatever it sees fit and may produce useful results, unexpected results, or even crash.
Code that invokes UB may work as intended on a specific system with a specific compiler, but will likely not work on another system, or with a different compiler, compiler version or compiler settings.
For managing dynamically allocated memory, the standard C library provides the functions
free(). In C99 and later, there is also
aligned_alloc(). Some systems also provide
Preprocessor and Macros
All preprocessor commands begins with the hash (pound) symbol
A C macro is just a preprocessor command that is defined using the
#define preprocessor directive. During the preprocessing stage, the C preprocessor (a part of the C compiler) simply substitutes the body of the macro wherever its name appears.
An operator in a programming language is a symbol that tells the compiler or interpreter to perform a specific mathematical, relational or logical operation and produce a final result.
C has many powerful operators.
Many C operators are binary operators, which means they have two operands. For example, in
a / b,
/ is a binary operator that accepts two operands (
There are some unary operators which take one operand (for example:
and only one ternary operator
An assertion is a predicate that the presented condition must be true at the moment the assertion is encountered by the software. Most common are simple assertions, which are validated at execution time. However, static assertions are checked at compile time.
In C, a string is not an intrinsic type. A C-string is the convention to have a one-dimensional array of characters which is terminated by a null-character, by a
This means that a C-string with a content of
"abc" will have four characters
See the basic introduction to strings example.
Arrays are derived data types, representing an ordered collection of values ("elements") of another type. Most arrays in C have a fixed number of elements of any one type, and its representation stores the elements contiguously in memory without gaps or padding. C allows multidimensional arrays whose elements are other arrays, and also arrays of pointers.
C supports dynamically allocated arrays whose size is determined at run time. C99 and later supports variable length arrays or VLAs.