Right Click to Search

Sunday, January 17, 2025

What is Constant Pointers [ Const Pointer ] in C Programming


What is Constant Pointers [ Const Pointer ] in C Programming :


  • As name suggests , Constant Pointers Cannot be modified . 
  • Modification in Integer to which it Points to is Allowed
  • Modification made in Pointer is Not Allowed
Syntax Declaration :
data_type * const Pointer_name ;
Live Example : 
           int i = 20;
           int * const ptr ;    // Declare Constant Pointer
           ptr = &i;
           *ptr = 20 ;          // Valid Statement
           ptr ++ ;              // Invalid Statement 


Explanation :

  1. In the Diagram Shown The at 2001 we have Store the value 15 .
  2. Constant Pointer is Pointer to that Variable [Pointer Stores address 2001]
  3. We cannot Change the Address stored in Pointer Variable i.e 2001 is fixed
  4. But we can Change the Value at 2001 i.e we can change value 15 to 20



Bookmark & Share

Tags / Keywords : |

Stumble
Delicious
Technorati
Twitter
Facebook

0 Comments:

Post a Comment

Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email

 

Learn C Programming Copyright © 2010 LKart Theme is Designed by Lasantha, Free Blogger Templates