From 743e1a320d542eea513482eae25020e2c409fd97 Mon Sep 17 00:00:00 2001 From: zleyyij <75810274+zleyyij@users.noreply.github.com> Date: Tue, 19 Nov 2024 20:57:20 -0700 Subject: [PATCH] vault backup: 2024-11-19 20:57:20 --- .../ECE1400/Chapter 17 Exercises.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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