Question: Assume that the structs are the same as the ones from the lab on authors and books. Does the following segment of code have any
Assume that the structs are the same as the ones from the lab on authors and books. Does the following segment of code have any memory violations? 1: bookArr[i].authors = (author_t* ) calloc(bookArr[i].numAuthors, sizeof(author_t)) 2: for (int j = 0; j < bookArr[i].numAuthors; j++) { 3: bookArr[i].authors[j].name = (char *) calloc(80 + 1, sizeof(char)); 4: scanf("%s", bookArr[i].authors[j].name) 5: scanf("%d", &bookArr[i].authors[j].birthYear); 6: scanf("%d", &bookArr[i].authors[j].publishings) 7: }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
