Answered step by step
Verified Expert Solution
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
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
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