I have found the const
rules in c to be very confusing. I want to know if there are known rules or a way to know what's allowed when dealing with const
/pointers to const
.
I will give an exmple:
Not allowed:
const int b=3;
int * const a=&b;
Allowed:
int b=3;
int * const a=&b;
Are there rules to know before compiling if the code that contain const
will compile? One thing I though about is -- and I want to know if it's a rule -- every time you write a line with const
, does there always have to be initialize after it? I know that there is some rule about what const
can/can't hold.