Right Click to Search

Saturday, January 9, 2025

Differencing or Subtracting Pointer in C Programming Language



Differencing Pointer in C Programming Language :
  1. Differencing Means Subtracting two Pointers.
  2. Subtraction gives the Total number of objects between them .
  3. Subtraction indicates "How apart the two Pointers are "
Example :
int n , *p ,*q ;
// P stores the address of Variable n
p = &n ; 
// Value of q is incremented by 4 bytes
q = p + 2 ;  
// Differencing two Pointers
printf("%d",q-p); 

Output : 2


Observations & Explanation : 
  1. Numerically Subtraction ( q-p ) differs by 4
  2. As both are Integers they are numerically Differed by 4 and Technically by 2 objects
  3. Suppose Both pointers of float the they will be differed numerically by 8 and Technically by 2 objects



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