sanman10535
Technical User
I have to find the error in the following code segments and fix it. Explain every error and assume the following has already happened,
int *zPtr;
int *aPtr = NULL;
int number, i;
int z [5] = {1, 2, 3, 4, 5};
zPtr = z;
(a) number = zPtr; /* use pointer to get the first value of the array */
(b) number = *zPtr [2]; /* assign element with subscript 2 to number */
(c) for (i = 0; i <= 5; i++) { /* print array z using zPtr */
printf (“%d”, zPtr );
}
(d) ++z;
Assume the statements in (a) – (d) happen independently.
Will someone help me with this question, because it's confusing the hell out of me.
int *zPtr;
int *aPtr = NULL;
int number, i;
int z [5] = {1, 2, 3, 4, 5};
zPtr = z;
(a) number = zPtr; /* use pointer to get the first value of the array */
(b) number = *zPtr [2]; /* assign element with subscript 2 to number */
(c) for (i = 0; i <= 5; i++) { /* print array z using zPtr */
printf (“%d”, zPtr );
}
(d) ++z;
Assume the statements in (a) – (d) happen independently.
Will someone help me with this question, because it's confusing the hell out of me.