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 an error looping over an array */ #define N 2
int main(){
  ...
// It is likely, although not certain, that the compiler // will choose to store a, vec and b next to each other. » float a=0, vec[N], b=0; // Initialise all the elements of vec to 1000 » for ( int j=1;j<=N; ++j) // Ooops! vecj=1000; » printf("a: %g b:%g\n", a, b); » return 0;
}
Memory

main(): for()

132
133
134
135
j = 1

main()

136
137
138
139
140
141
142
143
b = 0
vec[0] = 3.99792e-34
144
145
146
147
148
149
150
151
vec[1] = 1.4013e-45
a = 0

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

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

a: 1000 b:0
                                                                                                                                                                                                                                                                       

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