Skip to content

Instantly share code, notes, and snippets.

View kisssko's full-sized avatar
⁉️

Alexander Gurov kisssko

⁉️
  • Voronezh, Russia
View GitHub Profile
@kisssko
kisssko / const.c
Created December 11, 2019 10:50 — forked from burczyk/const.c
const int VS int const
The trick is to read the declaration backwards (right-to-left):
const int a = 1; // read as "a is an integer which is constant"
int const a = 1; // read as "a is a constant integer"
Both are the same thing. Therefore:
a = 2; // Can't do because a is constant
The reading backwards trick especially comes in handy when you're dealing with more complex declarations such as:
const char *s; // read as "s is a pointer to a char that is constant"