Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with pointer and array questions

Status
Not open for further replies.

sanman10535

Technical User
Mar 26, 2004
2
US
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.
 
Write a small program, with a) to d) as the next statement and see what error messages you get

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top