Question: 1. Fix the memory leak in the c code #include stdio.h #include stdlib.h #include string.h #define SIZE 16 int main() { char *data1, *data2; int

1. Fix the memory leak in the c code

#include stdio.h

#include stdlib.h

#include string.h #define SIZE 16 int main() { char *data1, *data2; int i; do { data1 = malloc (SIZE); printf ("input your username: "); scanf ("%s", data1); if (!strcmp (data1, "quit")) break; data2 = malloc (SIZE); for (i=0; i data2[i] = data1[i]; free (data1); printf ("data2 :%s: ", data2); } while (1); return 0; }

2. how many times is the write () system call invoked

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!