English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write an expression that retrieves the value in the location immediately after the location pointed to by the integer pointer variable ip .

i seem to not understand the question(why cant my book speek english).

2006-10-27 07:27:36 · 1 answers · asked by delonsampaio 1 in Computers & Internet Programming & Design

this is C/C++

2006-10-27 07:29:39 · update #1

1 answers

the question is really simple. You are given an integer pointer, ip. i.e. int *ip;
and you want to find out the integer value in the next location, where ip is pointing. The answer is simple

*(ip +1)

to explain it further consider following line of code

int ip[4] = {1,2,3,4}

printf("%d %d %d %d", *ip,*(ip + 1), *(ip +2), *(ip+3));

the output is 1 2 3 4.
when you declare an integer array ip, it actually creates a pointer of type integer and referred this pointer as ip.The next elements in array are stored consecutevly in the memory. Hence by doing *(ip +n), you can get the value of nth element.

2006-10-27 08:03:12 · answer #1 · answered by manoj Ransing 3 · 1 0

fedest.com, questions and answers