GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Tech FAQs  >  OOPS

 Print  |  
Question:  What is the difference between constant to pointer and pointer to constant?



February 02, 2006 05:20:54 #2
 venkatesh Microsoft Expert  Member Since: November 2005    Total Comments: 17 

RE: What is the difference between constant to pointer...
 

pointer to constant: If a pointer is pointing to constant it is called as pointer to constant.In this case we cannot change the content of constant.

eg :  const int n=5;

  int *p=&n;

in this case we cannot change the value of n.

constant pointer:  If we declare a pointer as constant we can change the contents of memory pointed by pointer.But we cannot change the pointer value i.e incrementing or decrementing of pointer address.

Eg : const int *p=n;

Here we can change the content of n,but we cannot increment or decrement of pointer p(p++ or ++p).

     

 

Back To Question