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...
struct proj { float mass; float pos[2]; float v[2]; struct proj *next; };
struct proj* newproj(struct proj *f){
  ...
» struct proj *new; » new=malloc(sizeof *new); » new->next=f; » return new;
} int main(){
  ...
» struct proj *first=NULL, *p=NULL, *togo=NULL; // Allocate a list of four » first=newproj(first); » first=newproj(first); » first=newproj(first); » first=newproj(first); // Now free the third, first->next->next » p=first->next;// Previous » togo=p->next; » p->next=togo->next; » free(togo); » togo=NULL; » return 0;
}
Memory

Allocated memory

128
129
130
131
132
133
134
135
128.mass = 4.35376406
128.pos[0] = 1.76296e-34
136
137
138
139
140
141
142
143
128.pos[1] = -8.07764e-07
128.v[0] = 8.60002e+25
144
145
146
147
148
149
150
151
128.v[1] = 1.11902e-33
128.next = -159567460

160
161
162
163
164
165
166
167
160.mass = -3.03442854e+11
160.pos[0] = 2.839e-31
168
169
170
171
172
173
174
175
160.pos[1] = 2.68248e-18
160.v[0] = 3.39764e+06
176
177
178
179
180
181
182
183
160.v[1] = 2.28525e+19
160.next = -152114618

192
193
194
195
196
197
198
199
192.mass = 1.28847842e-06
192.pos[0] = 5.78244e-08
200
201
202
203
204
205
206
207
192.pos[1] = -7.24463e+24
192.v[0] = 1.06715e-19
208
209
210
211
212
213
214
215
192.v[1] = 9.11818e-18
192.next = -158826671

224
225
226
227
228
229
230
231
224.mass = -1.29546572e-23
224.pos[0] = -2.69326e-35
232
233
234
235
236
237
238
239
224.pos[1] = -1.79474e+14
224.v[0] = 3.6198e-19
240
241
242
243
244
245
246
247
224.v[1] = -1.93385e-21
224.next = -152787007

newproj()

380
381
382
383
f = -4127639000
392
393
394
395
new = -4288374990

newproj()

380
381
382
383
f = NULL
392
393
394
395
new = -4288374990

newproj()

380
381
382
383
f = -4127638968
392
393
394
395
new = -4288374990

newproj()

380
381
382
383
f = -4127639032
392
393
394
395
new = -4288374990

main()

432
433
434
435
436
437
438
439
first = NULL
p = NULL
440
441
442
443
togo = NULL

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

The actual address of allocated memory is the
address shown plus 160735832 (0x994A258).

Show Advanced options

.
                                                                                                                                                                                                                                                                       

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