Skip to content

Instantly share code, notes, and snippets.

View jtepe's full-sized avatar
🌌

Jonas Tepe jtepe

🌌
View GitHub Profile
@jtepe
jtepe / constness.c
Last active June 11, 2016 09:16
Describing the const modifier in C
#include <stdio.h>
// s is a pointer to a pointer to a char which is const
// (i.e. the char is const not the pointer to a pointer).
// I may change the pointer (as is done here) but not
// the data it ultimately points to.
void constant_data(const char **s, char *t)
{
*s = t; // Ok. Change the pointer it points to
**s = 'c' // error: read-only variable is not assignable