E
Eric
Hi. I'm just reading through a section in my C book that deals with the
const type qualifier. It says, in relation to using the qualifier in
pointer declarations: "If the type qualifier is to be applied to the
pointer itself, it must be placed immediately before the identifier."
So, I tried this:
#include <stdio.h>
int main(int argc, char **argv)
{
int i = 10, j = 20;
int const *ptrToConst = &j;
ptrToConst = &i; // Oops - shouldn't be legal, right?
return 0;
}
Yet this program compiles fine in MSVC++ Express and gcc, even with '-W
-Wall -ansi -pedantic'. What gives? Did I misunderstand something?
const type qualifier. It says, in relation to using the qualifier in
pointer declarations: "If the type qualifier is to be applied to the
pointer itself, it must be placed immediately before the identifier."
So, I tried this:
#include <stdio.h>
int main(int argc, char **argv)
{
int i = 10, j = 20;
int const *ptrToConst = &j;
ptrToConst = &i; // Oops - shouldn't be legal, right?
return 0;
}
Yet this program compiles fine in MSVC++ Express and gcc, even with '-W
-Wall -ansi -pedantic'. What gives? Did I misunderstand something?