Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started