Answered step by step
Verified Expert Solution
Link Copied!

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

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

Question

C10H14 what is the structure from the spectra? Problem 121

Answered: 1 week ago