Archived

This topic is now archived and is closed to further replies.

pointer/array + index

This topic is 5585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have an array of chars: char* Stream=new char[10]; Now I want to use the fourth element. Do these two examples mean the same: 1: Stream[4]; 2: Pointer=Stream; Pointer+4; Sorry my English, I hope you understand what i mean.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if you mean, can i access the 4th cell like this, then no. in the second example. it should be *(p+4) = ... The first example is accessing the cell with array notation, and in the second, with pointer notation.

Share this post


Link to post
Share on other sites
Your code to advance the pointer is correct. Remember to dereference it to access the content.

Kuphryn

[edited by - kuphryn on October 2, 2002 5:54:33 PM]

Share this post


Link to post
Share on other sites