Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions