GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  Intergraph  >  C
Go To First  |  Previous Question  |  
 C  |  Question 2 of 2    Print  
what is the difference between *ptr++ and++*ptr

  
Total Answers and Comments: 3 Last Update: August 23, 2009     Asked by: saranyamahendran 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: ziiz996
 
++*ptrmeans increment the pointer before using it.
*ptr++means increment the pointer after using it.


Above answer was rated as good by the following members:
ashishchaudharicool
February 10, 2008 03:07:43   #1  
raj5045 Member Since: February 2008   Contribution: 2    

RE: what is the difference between *ptr++ and++*ptr
*ptr++ gives the value the pointer is pointing to and then increment the pointer to point to next location.for e g

char *ptr "hello";

*ptr++ will give 'h' and then ptr points to 'e'

In case of ++*ptr the value at which the pointer ptr points to is incremented by 1.
In above case ++*ptr will give 'i' at the place of 'h'.The pointer still points to the first location that has the new value 'i' now.

 
Is this answer useful? Yes | No
August 21, 2009 14:12:21   #2  
ziiz996 Member Since: August 2009   Contribution: 1    

RE: what is the difference between *ptr++ and++*ptr
++*ptrmeans increment the pointer before using it.
*ptr++means increment the pointer after using it.

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
August 23, 2009 21:05:54   #3  
myogeshchavan97 Member Since: December 2008   Contribution: 28    

RE: what is the difference between *ptr++ and++*ptr
*ptr++ increment the pointer ptr and ++*ptr increments the the value located at which ptr is pointing to .
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape