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

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -