Pointer arithmetic homework question

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2005
Posts: 27
Reputation: jack223 is an unknown quantity at this point 
Solved Threads: 0
jack223 jack223 is offline Offline
Light Poster

Pointer arithmetic homework question

 
0
  #1
Feb 14th, 2006
This is one of my hw question and I can't find the answer from the textbook.

Question: A function that modifies an array by pointer arithmetic (e.g., ++ptr) to process every value should have a parameter that is?

a) a nonconstant pointer to nonconstant data
b) a nonconstant pointer to constant data
c) a constant pointer to nonconstant data
d) a constant pointer to constant data

My guess is either a or d but i'm not sure...any help plz!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,508
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1480
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Pointer arithmetic homework question

 
0
  #2
Feb 14th, 2006
The clues in the question are modify data and ++ptr. Both these need non-constants. So the only possible answer is a).
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 27
Reputation: jack223 is an unknown quantity at this point 
Solved Threads: 0
jack223 jack223 is offline Offline
Light Poster

Re: Pointer arithmetic homework question

 
0
  #3
Feb 14th, 2006
Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC