africanmasks
- 11
- 0
Homework Statement
Suppose we have the following program segments:
int *zPtr;
int *aPtr = NULL;
void *sPtr = NULL;
int number,i;
int z[5] = {1,2,3,4,5};
sPtr = z;
point out the error of the following code:
(a) ++zPtr;
(b) number = zPtr;
(c) number = *zPtr[2];
(d) for(int i=0;i<=5;i++)
printf("%d ", zPtr);
(e) number = *sPtr;
(f) ++z;
Homework Equations
None.
The Attempt at a Solution
A.) It should be (*zPtr)++. Whatever zPtr is pointing to should be incremented, not the pointer.
B.) Should zPtr be assigned to the address of number? zPtr=&number;
C.) Don't Know
D.) Don't Know
E.) Don't Know
F.) Arrays cannot be incremented.