Skip to content
EMPS intranet

Back to top

Note

  • This code has been compiled to show the internal calculations of the addresses of array elements like this: 824.
Hi!   Hi!           Start program

Try stepping through the code


  Value and type of last evaluated expression: Address of array element: Address of array elementx:  (none)

Your browser does not support the canvas element which will make some the features unavailable.

If you are using Internet Explorer within the University of Exeter try going to the Settings menu (probably the gear shape at the top right of this page), selecting "Compatibility View settings", unchecking "Display intranet sites in Compatibility View" and reloading this page.

Code

 Header...
// // Error passing an array to a function // #define N 4 void printarray (int output[N]);
int main(){ » int num[N]={1,2,3,4}; » printarray(numN);// !!! » return 0; }
...
void printarray(int output[N]){ » int i; » for (i=0; i<N; ++i) { » printf("%d\n", outputi); } }
...
Memory

printarray()

132
133
134
135
i = -6748956
152
153
154
155
output = 620

main()

168
169
170
171
172
173
174
175
num[0] = 1
num[1] = 2
176
177
178
179
180
181
182
183
num[2] = 3
num[3] = 4

NB: the actual memory address of each variable is the
address shown plus 4288217720 (0xFF990278).

Show Advanced options

.
Show output (Before looking at the output, work out what you think it put should be and see if you are right.)

Output

-6742794
0
-6742787
-6742766
                                                                                                                                                                                                                                                                       

Validate   Link-check © Copyright & disclaimer Share
Back to top