I am working my way through a c programming book and I am a little confused with the const modifier. It says in my book that after you declare a variable with the const modifier, the content of a variable cannot be changed. But if i run this program:
#include <stdio.h>
int main(int argc, char *argv[])
{
int const x = 10;
x = 54;
printf("%i",x);
system("PAUSE");
return 0;
}
It compiles fine and I was able to change the contents of the variable. The only thing that happend was my compiler (bloodshed dev c++) give me a warning about trying to change a read only variable. So is that the only purpose of the const modifier, to give you a warning if you try to change it?