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


![struct actor { char name[32]; struct actor "next char "name }"head =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f333a06c775_49666f333a01d900.jpg)


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
Get step-by-step solutions from verified subject matter experts
