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 functions // #define VALUES 4 // Note: the two forms of the prototype: one with the // dimension, which is ignore, and one without. void setuparray (int input[VALUES]); void printarray (int output[]);
int main(){
  ...
» int num[VALUES]; » setuparray(num); » printarray(num); » return 0;
} void setuparray(int input[VALUES]){
  ...
» int i; // Initialise to uninteresting values » for (i=0; i<VALUES; ++i) inputi=i;
} void printarray(int output[]){
  ...
» int i; » for (i=0; i<VALUES; ++i) { » printf("%d\n", outputi); }
}
Memory

printarray()

132
133
134
135
output = 212
144
145
146
147
i = -6231544

setuparray()

148
149
150
151
input = 212
160
161
162
163
i = 2

main()

212
213
214
215
num[0] = -144870370
216
217
218
219
220
221
222
223
num[1] = 134536842
num[2] = 134536646
224
225
226
227
num[3] = 1

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

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