I am trying to learn the constant integer pointer and it's behavior;
#include<stdio.h>
void test1(int*);
int main()
{
const int b=20;
const int *q;
q=&b;
test1(q); //compiler will give warning
printf("value of b=%d\n",b); // here modified value of b is printing
}
void test1(int *ptr)
{
*ptr=50; // HERE constant integer in the main is modified , but how?
}
In the above snippet I am intentionally passing the constant integer pointer to the function that expects an integer pointer argument, what I am unable to comprehend is how is value of the variable "b" which is constant integer is updating, even being a constant integer?