Exforsys

Online Training

How is it Evaluated?

This is a discussion on How is it Evaluated? within the C and C++ forums, part of the Programming Talk category; I want to know how *p++ gets evaluated as p being declared as a integer pointer. If anyone could explain ...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-26-2007, 04:36 PM
Senior Member
 
Join Date: Apr 2006
Posts: 153
cyrus is on a distinguished road
How is it Evaluated?

I want to know how *p++ gets evaluated as p being declared as a integer pointer. If anyone could explain the above with an example it would help me a lot.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-14-2007, 05:27 PM
Senior Member
 
Join Date: Apr 2006
Posts: 162
sammy is on a distinguished road
In C programming both indirection operator and ++ operator takes the same level of precedence and the associativity is from right to left. So ++ gets evaluated first which means the address of p gets incremented and then the contents is retrieved from that and assigned to the variable. That is if you have address that is value of p as 1000 and contents of 1000 as 5. Then *p++ gets evaluated as 1000 gets incremented. Since it is integer it is incremented by 4 bytes which gives 1004 and contents of 1004 are accessed. This is how *p++ works.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
How to find second max sal of employee with the co chandraismoon Oracle Tutorials 7 05-16-2008 04:08 AM


All times are GMT -4. The time now is 11:55 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.