pointer/array + index

Started by
1 comment, last by kudi 21 years, 6 months ago
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.
The problem of Object Oriented Programming:Everybody tells you how to use his classes, but nobody how not to do it !
Advertisement
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]

This topic is closed to new replies.

Advertisement