Question: Which code fragment shall justifiably use malloc()? In other words, which malloc() cannot be replaced with static allocation? int *data; data = malloc (sizeof

Which code fragment shall justifiably use malloc()? In other words, which malloc() cannot be replaced with

Which code fragment shall justifiably use malloc()? In other words, which malloc() cannot be replaced with static allocation? int *data; data = malloc (sizeof (int) * 100); struct sigaction *sa; sa malloc (sizeof(struct sigaction)); char *s; s malloc (sizeof (char)); int size, *array; fscanf (stdin, "%d", &size); array malloc(size*sizeof (int)); Which code fragment shall justifiably use malloc()? In other words, which malloc() cannot be replaced with static allocation? int *data; data = malloc (sizeof (int) * 100); struct sigaction *sa; sa malloc (sizeof(struct sigaction)); char *s; s malloc(sizeof (char)); int size, *array; fscanf (stdin, "%d", &size); array malloc (size* sizeof (int));

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below The correct code fragment should typically use malloc in other words which malloc cannot be replaced with static allocation The correct ans... View full answer

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 Programming Questions!