954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Pointer arithmetic homework question

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!!

jack223
Light Poster
27 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

The clues in the question are modify data and ++ptr. Both these need non-constants. So the only possible answer is a).

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Thanks

jack223
Light Poster
27 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You