pointer/array + index
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.
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.
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]
Kuphryn
[edited by - kuphryn on October 2, 2002 5:54:33 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement