I have my TC++ help file which has the following in it:
const my_age = 39;
_______________ ____________
WARNING: A const variable can be indirectly modified by a
pointer, as in
the following:
*(int *)&my_age = 35;
When the const modifier is used with a pointer parameter in
a function's
parameter list, the function cannot modify the variable
that the pointer
points to. For example,
int printf (const char *format, ...);
Here the printf function is prevented from modifying the
format string.
_______________ __
I can't figure out what they are trying to say.
Could someone help?
TIA.
--
main(){char s[40]="sbwjAeftqbnnf e/dpn!ps!CSbwjACj hgppu/dpn";
int i;for(i=0;i<39; putchar(s[i++]-1));return 0;}
const my_age = 39;
_______________ ____________
WARNING: A const variable can be indirectly modified by a
pointer, as in
the following:
*(int *)&my_age = 35;
When the const modifier is used with a pointer parameter in
a function's
parameter list, the function cannot modify the variable
that the pointer
points to. For example,
int printf (const char *format, ...);
Here the printf function is prevented from modifying the
format string.
_______________ __
I can't figure out what they are trying to say.
Could someone help?
TIA.
--
main(){char s[40]="sbwjAeftqbnnf e/dpn!ps!CSbwjACj hgppu/dpn";
int i;for(i=0;i<39; putchar(s[i++]-1));return 0;}
Comment