Wednesday, 27 September 2023

Chapter 27 // Exercise 2, 3 - Principles & Practice Using C++

In this exercise I'm using Visual Studio 2019 and ISO C11 Standard.

Chapter 27 // Exercise 2

Complete the intrusive List example in section 27.9 and test it using every function.

This was quite a painful exercise. Mainly because I hate linked lists and they confuse me with their mPrev->mNext->mPrev malarky but this time I had to do it in C! C also just has so many parenthesis.

Chapter 27 // Exercise 3

"Pretty up" the intrusive List example in section 27.9 as best you can to make it convenient to use. Do catch/handle as many errors as you can. it is fair game to change the details of the struct definitions, to use macros, whatever.

So I turned the code into my usual style and found a bug? I'm not sure but I couldn't get it to run using the code in the book. In the main() function it needs to be struct Link* curr. I think he did that on purpose though as the for loop doesn't work otherwise because a List doesn't have suc as a member variable.

Apart from that, I didn't really bother with the other things.

Chapter 27 // Exercise 2 - Principles & Practice Using C++


No comments:

Post a Comment