Consider the following statements:
int *pFarr, *pVarr;
int farr[3] = {11,22,33};
int varr[3] = {7,8,9};
pFarr = &(farr[0]);
pVarr = varr;
At this point, both pointers point to the beginning of each address of the corresponding array. For * pFarr, we are now looking at 11 and for * pVarr, 7.
Equally, if I request the contents of each array through * farr and * varr, I also get 11 and 7.
So far so good.
Now try pFarr++and pVarr++. Fine. Now we look at 22 and 8, as expected.
But now...
An attempt to move up farr++and varr++... and we get "the wrong type of argument to increase".
Now I find out the difference between an array pointer and a regular pointer, but since their behavior is similar, why is this a limitation?
, , , , , , !?
working_on_pointers ( pFarr, farr ); // calling with expected parameters
working_on_pointers ( farr, pFarr ); // calling with inverted parameters
.
void working_on_pointers ( int *pExpect, int aExpect[] ) {
printf("%i", *pExpect);
printf("%i", *aExpect);
pExpect++;
aExpect++;
printf("%i", *pExpect);
printf("%i", *aExpect);
}
- , , ?
.
: Noobs, , : http://www.panix.com/~elflord/cpp/gotchas/index.shtml b >