So you think you know C? (2016)
11–20 of 344 posts
Re: So you think you know C? (2016)
#12Answered the rest, IDK.
Laughed! Great exercize.
Re: So you think you know C? (2016)
#13Re: So you think you know C? (2016)
#14Re: So you think you know C? (2016)
#15OK you tricked me. But the test would have been better if the answer was "undefined behavior" instead of "I don't know".
Re: So you think you know C? (2016)
#16Failed all of them. I totally agree with what the author is writing. Don’t presume anything but measure. I also tend to code in a way that it’s not necessary to know all the intricacies. Its not as clever as many like and often makes for longer code but is usually easier to read.
I think that's exactly the wrong takeaway here. Most of these have a well-defined result on a given platform (host + abi). You can measure that result. But it'll be different on a different platform. And the others don't have a well-defined result — a real-world compiler will produce a result, and you can measure that, but it might be different tomorrow. Unless you know the difference between platform-specific behavior and undefined behavior, you don't know which ones to avoid.
Re: So you think you know C? (2016)
#17I've worked on 16 bit C code, 32 and now 64 bit code. So I knew that the behavior was implementation and optimization dependent. :)
Ignorance is bliss in C.
Re: So you think you know C? (2016)
#18OK you tricked me. But the test would have been better if the answer was "undefined behavior" instead of "I don't know".
Not all of them are undefined behavior
Re: So you think you know C? (2016)
#19My score is 3/5. One immediate redflag I have noticed is using "int", "char", "short" as if they have a definite size. They don't. C standard only guarantees a minimum size. For example, many PDPs are 36-bit. Assuming the size of a variable is a common practice nowadays, but at least one should use uint8_t, int32_t, etc. from stdint.h. But I was still tricked, it should be obvious in hindsight, 12 years of schooling…
This test.. it reverses that entirely.
Re: So you think you know C? (2016)
#20At the end of the test, the author talks about automation programming for a nuclear power plant. I don’t think I could ever sleep the same at night after writing something like that.