I finally wanted to continue my foray into C. But, shockingly, my VM in Virtual Box refuses to start. And neither does a new VM.
Today I did Excercise 20 & 22. The Debug macros presented in chapter 20 look useful, but again I have to think, that I could have never come up with something like that. Writing "goto" felt strange, though. But I get what it's used for and it actually helps structure the program.
I can't say much about chapter 22, but I noticed that Scope of variables is something that needs special attention in C, especially regarding the local scope within control structures.
It's monday again. Mondays are not the best days. Anyway, my goal was to do something every day, so I decided to skip Excercise 20 for today and concentrate at Exercise 21. It offered an overview about the datatypes and control structures in C. I definitely have to come back to them. I think the more I use them the more cnfident I will become in their use. In general there was not much new but the details vary from the languages I'm used to.
Today I did no new chapters because I spend the day with not computer related things. In the evening I decided to revisit the exercises 16 & 17 so I'm prepared to do excercise 18 and the following exercises tomorrow.
I searched for ways to make the program work with arbitrarily sized row numbers and data fields. I also explored how to work around the problems with strncpy.
The strncpy problem was quite easy to solve. Just add code that sets the last char in the target string always \0. Or just don't use this function at all, like lots of sources recommend.
Reworking the program to make it work with arbitrarily sized data was more challanging and I have to admit, that I failed for now. I will probably come back to it later, but for now I will continue with the next exercises.
I did Exercise 16 & 17 today. Initially I had planned to do Excercise 18 too, but I have to admit, that it was enough for the evening. Understanding the Structs and Pointers and the working of Stack and Heap proved challenging and interesting. I spent almost 3 hours fiddling and toying with the example programs and I'm still not quite finished with "Extra Credit" portion of No. 17. Inbetween I wrote my own little program to try out some string and string pointer operations, which greatly improved my understanding of the topic.
Structs are really an interesting topic. They remind me of the structures in ABAP, though on a much lower level. They also feel a bit like a raw sort of proto objects to me.
I learned about while, if and switch. The topics were not exactly new for me, but there are still small differences to languages that I'm used to.
An interesting thing about the switch statement in C is that the cases have "fall through" which could be translated to "Durchfall" which means "diarrhoea". Now I know where this idea in Java comes from.
Excercise 14 offered an insightful first overview about functions in C. I suspect that there is more to it later in the course.