How does a ‘const struct’ differ from a ‘struct’?

The const part really applies to the variable, not the structure itself.

e.g. @Andreas correctly says:

const struct {
    int x;
    int y;
} foo = {10, 20};
foo.x = 5; //Error

But the important thing is that variable foo is constant, not the struct definition itself.
You could equally write that as:

struct apoint {
    int x;
    int y;
};

const struct apoint foo = {10, 20};
foo.x = 5; // Error

struct apoint bar = {10, 20};
bar.x = 5; // Okay

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)