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 main()

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...
// Check display of arrays v pointers #define LEN 4
int main(){
  ...
» float * * *p=NULL; » int arr[2][2][2]; » p=malloc(2*sizeof *p); // p[0] = malloc(LEN * sizeof *p[0]); » p1=malloc(LEN*sizeof *p[1]); » p[1]2=malloc(LEN*sizeof *p[1][2]); » p[1][2]3=13.1; » arr[1][1]0=1.7; » printf("%d\n", arr110); » return 0;
}
Memory

Allocated memory

128
129
130
131
132
133
134
135
128[0] = 1556774808
128[1] =

144
145
146
147
148
149
150
151
144[0] = 1023656785
144[1] = 173390380
152
153
154
155
156
157
158
159
144[2] = 334438584
144[3] =

168
169
170
171
172
173
174
175
168[0] = 4.77587e+28
168[1] = -4.99621e+37
176
177
178
179
180
181
182
183
168[2] = 5.75607e+12
168[3] = 1.70888e-38

main()

312
313
314
315
316
317
318
319
p = NULL
arr[0][0][0] = 1
320
321
322
323
324
325
326
327
arr[0][0][1] = -6192364
arr[0][1][0] = -144757336
328
329
330
331
332
333
334
335
arr[0][1][1] = 1
arr[1][0][0] = 200
336
337
338
339
340
341
342
343
arr[1][0][1] = -144420025
arr[1][1][0] = -143028224
344
345
346
347
arr[1][1][1] = 1

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

The actual address of allocated memory is the
address shown plus 144204376 (0x8986258).

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

1
                                                                                                                                                                                                                                                                       

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