vault backup: 2024-11-19 20:57:20
This commit is contained in:
parent
d5d9a922db
commit
743e1a320d
@ -26,6 +26,16 @@ struct {
|
||||
> Which of the following statements are legal?
|
||||
|
||||
(a) `p->b = ' ';`
|
||||
(b) `p->e[3] = 10;`
|
||||
(c) `(*p).d.a = '*';`
|
||||
(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
|
Loading…
Reference in New Issue
Block a user