Difference between normal pointer and const pointer in c -


Actually I do not know the difference between a normal pointer and a point pointer if I use the code below works fine . But when i int * ptr = & amp; Num; to int * const ptr = & amp; Var1; Change it will not work. What is the difference between a normal pointer and a constant pointer, can it tell?

  int main (zero) {int num = 20; Int * ptr = & amp; Num; // if i`ll int * const ptr = & amp; Var1; ', Then this is some error * ptr = 20; // valid PTR ++; // valid return 0; }  

  int * const ptr = & amp; Num;  

will make a constant indicator for an int. This indicates that data can be changed, but Pointer can not do it himself.

You can not change the pointer:

  ptr ++;  

But you can change the data:

  * ptr = 1234;  

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -