diff --git a/education/software development/ECE1400/Chapter 17 Exercises.md b/education/software development/ECE1400/Chapter 17 Exercises.md index 78dd595..4d0498c 100644 --- a/education/software development/ECE1400/Chapter 17 Exercises.md +++ b/education/software development/ECE1400/Chapter 17 Exercises.md @@ -26,6 +26,16 @@ struct { > Which of the following statements are legal? (a) `p->b = ' ';` -(b) `p->e[3] = 10;` -(c) `(*p).d.a = '*';` -(d) `p->d->c = 20;` \ No newline at end of file +(b) `p->e[3] = 10;` - **Legal** +(c) `(*p).d.a = '*';` - **Legal** +(d) `p->d->c = 20;` + +--- + +> **7.** The following loop is supposed to delete all nodes from a linked list and release the memory that they occupy. Unfortunately, the loop is incorrect. Explain what's wrong with it and show how to fix the bug. +```c +for (p = first; p != NULL; p = p->next) + free(p); +``` + +The above loop won't function because it deallocates an entry, resulting \ No newline at end of file