• Home
  • Tutorials
  • Interviews
  • Info Seed
  • Forums
  • Projects
  • Links
  • Contact Us
C Language
C POINTERS
INTRODUCTION
What are POINTERS?
Illustration of POINTER assignments
Illustration - II
Illustration - III
POINTER arithmetic- POINTER + number
POINTER - number
POINTER - POINTER
NULL POINTER
Common Errors
DEREFERENCING NULL
DANGLING POINTER
REFERENCING DE-ALLOCATED MEMORY
MEMORY MANAGEMENT

 

 

ILLUSTRATION-II

*y=4// ERROR as no pointee is assigned

Remember that using pointers, we need to do two tasks: one creating a pointer and other as assigning a pointee to pointer. In the above example one task was done and hence the ERROR.

  

y=x; // this statement assigns the pointee of x to y also. Hence pointee of both x and y are same.

Memory map at this moment is as:

www.exploreroots.com

*y=4; //As pointee for both x and y are same. Hence changing the value of one would change the same for other.

Memory map at this moment is as:

www.exploreroots.com

y=&j;// Now pointer y is assigned a new pointee j.

Memory map at this moment is as:

www.exploreroots.com

Hence now both pointers points to different memory locations.

*y=8;

 Memory map at this moment is as:

www.exploreroots.com

 


previous next
| Copyright © 2009 exploreroots- All Rights Reserved | Disclaimer |