Archived

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

kudi

pointer/array + index

Recommended Posts

kudi    244
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   
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
kuphryn    210
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