Easy enough. I had to look up exactly what a format string was, but that’s fine. Zed flagged it up for looking. This is quite a lot like Python’s %s and %d functionality. Just different syntax.
So, trying to break the printfile, I found that
would look up height (an int that gave numeric value) and find it was 72. So it would then look up the character 72 in ASCII, and return an upper case H. That’s the DEC version, by default.
Unicode gives me a WTF character. I assume I need a different library to deal with that.
A missing age variable gives me a ludicrous age, but doesn’t crash the program. I can embed the width of the returned number or string in the %symbol by using %+4i – width of 4 digits, including a sign that will always be shown or %10.3f – that would give a minimum width of 10 digits including a decimal point, and 3 figures after the point. A – will left justify shit. I’ve been told that C is really concise, and that’s a good example of using not very many characters to type stuff. It’s not exactly confusing form with function – the format characters sit over the stringy bits. They just sit over it inside the same bit of typing.
r is a return to the start of the line without a new line. I can overwrite the earlier part of a string with it.
So, I’ve got various ways of breaking printf(), but those are mostly bad typing. I can also accidentally cover over a result, or leave big spaces in a result.
The last bit of the Extra Credit wouldn’t be clear if I hadn’t done a bit of research already. The ‘list’ of the makefile isn’t, I think, a thing Zed’s defined. In Ex 2 I cleaned up a bit when I took out ex1 as a dependency for all:. Now, I’m going to make it so ‘clean’ and ‘all’ have the lists I want inside them. For the moment I’m typing out all the names, but I’m aware there’s a way I can substitute in everything that’s in a folder, and stuff like that. I don’t mind having had to look up what the list and the dependencies were – Zed’s trying to make new programmers thing for themselves. I am concerned I’ll be trying to look up too much, which is a problem I always have. Knowing when to stop is a skill you don’t pick up until you know what’s important, and you don’t know what’s important until you’ve practiced for a while. So, every time my brain seems too full, I’ve probably gone too far.
www.le.ac.uk/users/rjm1/cotter/page_31.htm has a good list of width/precision stuff, but the examples are odd.
– I’ve eMailed the owner there to ask how the heck* that works. It breaks my program by printing out the last parts of my previous lines. It compiles (badly) and then it betrays me. Le whut?
* I used different words.