Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 Consider the given Program A and Program B. Answer all the five questions based on these two program. struct actor { struct actor

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Question 1 Consider the given Program A and Program B. Answer all the five questions based on these two program. struct actor { struct actor { char name[32]; struct actor "next char "name }"head = NULL; char *get name() struct actor "next }"head = NULL; char *get name() char *q, q (char *) malloc(32); printf("Please enter a name: "); scanf("%s", q): return q; char *q, q = (char *) malloc(32); printf("Please enter a name: "); scanf("%s", q): return q; int insertion() (struct actor *c; char *n; int insertion() {struct actor *c; char *n; c malloc(sizeof(struct actor); c malloc(sizeof(struct actor)); if (c == 0) { printf("out of memoryln"); return -1;] n = get-name(); strcpy(c-name, n); free(n); c->next head; head c; return 1 printf("out of memoryln"); return -1;] c->name get name): c->next-head; head c; return 1 Which piece of code has memory leak? a. Neither Program A nor Program B b. Both Program A and Program B O C. Program A o d. Program B Question 1 Consider the given Program A and Program B. Answer all the five questions based on these two program. struct actor { struct actor { char name[32]; struct actor "next char "name }"head = NULL; char *get name() struct actor "next }"head = NULL; char *get name() char *q, q (char *) malloc(32); printf("Please enter a name: "); scanf("%s", q): return q; char *q, q = (char *) malloc(32); printf("Please enter a name: "); scanf("%s", q): return q; int insertion() (struct actor *c; char *n; int insertion() {struct actor *c; char *n; c malloc(sizeof(struct actor); c malloc(sizeof(struct actor)); if (c == 0) { printf("out of memoryln"); return -1;] n = get-name(); strcpy(c-name, n); free(n); c->next head; head c; return 1 printf("out of memoryln"); return -1;] c->name get name): c->next-head; head c; return 1 Which piece of code has memory leak? a. Neither Program A nor Program B b. Both Program A and Program B O C. Program A o d. Program B

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

Explain the various methods of job evaluation

Answered: 1 week ago

Question

Differentiate Personnel Management and Human Resource Management

Answered: 1 week ago

Question

Describe the functions of Human resource management

Answered: 1 week ago