I'm trying to figure out the value of pointers after the following code snippet
Code:
int s[8] ;
int *iptr1, *iptr2 ;
int **iptr3 ;
for (int i = 0 ; i < 8 ; i++)
s[i] = 7 - i ;
iptr1 = s ;
iptr2 = &s[3] ;
iptr3 = &iptr1 ;
*iptr1 = 5 ;
*iptr2 = 11 ;
**iptr3 = 14 ;
I neeed to find what the value of iptr1, iptr2, and iptr3 are after the code is executed. I'm having trouble understanding how pointers work, so any clarity on this would be appreciated. Thanks.
I neeed to find what the value of iptr1, iptr2, and iptr3 are after the code is executed. I'm having trouble understanding how pointers work, so any clarity on this would be appreciated. Thanks.
Why don't you give it a shot yourself first? Explain what you think each line means and what the value of each variable is. Then we'll tell you if it's correct and give you further advice.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Bookmarks