Skip to content
EMPS intranet

Back to top
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 // #define VALUES 3 void printarray (int output[VALUES]);
int main(){
  ...
» int numbers[VALUES]; // Initialise to uninteresting values » for ( int i=0;i<VALUES; ++i) { » numbersi=i; } » printarray(numbers); » return 0;
} void printarray(int output[VALUES]){
  ...
» int k; » for (k=0; k<VALUES; ++k) { » printf("%d\n", outputk); }
}
Memory

printarray()

132
133
134
135
output = 232
144
145
146
147
k = -7569112

main(): for()

228
229
230
231
i = 0

main()

232
233
234
235
236
237
238
239
numbers[0] = 134536578
numbers[1] = 134536382
240
241
242
243
numbers[2] = 1

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

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
                                                                                                                                                                                                                                                                       

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