Question: Compile with g so you can debug it Run it in gdb. Find the errors. Some of the errors you can handle within gdb by
Compile with g so you can debug it
Run it in gdb. Find the errors.
Some of the errors you can handle within gdb by setting values; other errors are logic errors that you cant fix.
Fix the errors in the .c file, recompile, until it runs correctly. In C
#include
struct mystruct { struct mystruct * next; int val; };
int recur (int n) { if (n == 0) return; else recur (n - 1); }
int divide (a, b) { return (a / b); }
chase (struct mystruct *p) { printf ("%d ", p-> val); chase (p-> next); }
int main () { struct mystruct *s1, *s2;
recur (5); divide (10, 5); divide (10, 0);
s1 = (struct mystruct * ) malloc (sizeof (struct mystruct)); s1->val = 1; s2 = (struct mystruct * ) malloc (sizeof (struct mystruct)); s2->val = 2;
s1-> next = s2;
chase (s1);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
