Question: AND PLEASE ANSWER Q2. swap2.s void swap (int *px, int *py) { int *temp; *temp = *px; *px = *py; *py = *temp; } (Exercise)

AND PLEASE ANSWER Q2.
swap2.s
void swap (int *px, int *py) { int *temp; *temp = *px; *px = *py; *py = *temp; }
(Exercise) Create swap.c Supply the definition of a C procedure proc to be called in the main program immediately prior to the call to the buggy swap (swap2.s) that will guarantee that swap will crash when the uninitialized temp pointer is dereferenced (it should cause a crash on temp). Also explain why your call guarantees this crash. Hint: your proc procedure will leave something on the stack. int main int a - 1, b- 2; proc(/* Some args might go here */); swap (&a, &b) Q2. Explain how you guarantee it crashing with what is in proc
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
