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...
// // Demonstrate passing an array to a function // using "proper" canonical parameter declaration // #define VALUES 4 void printarray (int *output);
int main(){
  ...
» int num[VALUES]; » int i; // Initialise to uninteresting values » for (i=0; i<VALUES; ++i) numi=i; » printarray(num); » return 0;
} void printarray(int *output){
  ...
» int i; » for (i=0; i<VALUES; ++i) { » printf("%d\n", outputi); }
}
Memory

printarray()

132
133
134
135
output = 228
144
145
146
147
i = -4520776

main()

224
225
226
227
228
229
230
231
i = 1
num[0] = -144796642
232
233
234
235
236
237
238
239
num[1] = 134536646
num[2] = 134536450
240
241
242
243
num[3] = 1

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

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

0
1
2
3
                                                                                                                                                                                                                                                                       

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