Log in

View Full Version : Trace program


deadlock75
2004-11-27, 12:18 PM
I need some help I only now what its going to output but the only problem which I do not know how is trace the execution.

#include <stdio.h>

main()

struct aa{
int x;
char z; } *p, *q;
p=(struct aa*)malloc (sizeof(struct aa));
p-> x=5;
p-> z='X';
printf("x's field %d, z's field %c \n", p->x, p->z);
free(p);
q=(struct aa*)malloc (sizeof(struct aa));
q-> x=6;
q-> z='Y';
printf("x's field %d, z's field %c\n", p->x, p->z);
printf("with q x's field %d, z's field %c\n", q->x, q->z);
}

WetWired
2004-11-27, 04:41 PM
What do you mean you don't know how to trace the execution? Do you understand C or not?

Demosthenes
2004-11-27, 05:03 PM
See if your compiler comes with a built-in stepper tool. That program doesn't seem too difficult to follow, though.