Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 1.25 KB

c99.md

File metadata and controls

25 lines (20 loc) · 1.25 KB

Using C99 Features

C99, i.e. the C standard released in 1999 added a lot of features that make C code much more readable. Examples include:

Declarations anywhere in block
In C99, you can declare and initialize a variable anywhere: int x = 3; Declare variables where they can be initialized; don't put all variables at the top of a function.

Declaration in for loop init-clause
In C99, you can write for (int i = 0; i < n; ++i). This is ideal when i is only needed inside the loop.

Compound Literals and Designated Initializers
In C99, you can assign a struct like:

p = (struct point) {.x = 3, .y = 5};

_Bool and the convenience alias bool
In C99, you can use _Bool instead of int for variables which can only be true or false. #include <stdbool.h> for the bool convenience alias.