Question: 1 . ( 6 points ) Consider the code below: 1 # include < stdio . h > 2 # include < stdlib . h

1.(6 points) Consider the code below:
1 # include < stdio .h >
2 # include < stdlib .h >
3
4 struct db_entry {
5 char * name ;
6 char * value ;
7};
8
9 void dbe_print ( struct db_entry * entry )
10{
11 fprintf ( stdout ,"%s =>%s
", entry -> name , entry -> value ) ;
12}
13
14 int main (int argc , char ** argv )
15{
16 struct db_entry * e ;
17 e -> name =" hocus pocus ";
18 e -> value =" focus ";
19 dbe_print ( e ) ;
20 return 0;
21}
This code compiles, but crashes when it is run. Suspecting a problem with dbe print,
you comment out the line of code that prints the entry (11), however the program still
crashes! You suspect the crash is caused by a memory allocation problem.
(a) What is the reason for the crash?
21 January 2024 Page 1
CSSE 132 Winter 2023-2024
(b) Without changing existing code, you can solve this problem by inserting additional
code to correct the crash and resolve the memory issue.
Indicate what code you would insert and the line numbers immediately before
where your code will be inserted. (For example, insert this code after line 19 or
insert this code just above line 9.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!