Live data from Hacker News

So you think you know C? (2016)

wordsandbuttons.online

1–10 of 344 posts

Re: So you think you know C? (2016)

#5
Failed 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.

Re: So you think you know C? (2016)

#7
post #2

tl;dr - C has some undefined behavior, if you plan on things working based on your experience with one compiler and one computer, you will be surprised.

I wonder how many C programmers have experience with writing multi platform/compiler code. I have done a lot of C and C++ but never had to port it so I would not be surprised if I had made a ton of mistakes.

Re: So you think you know C? (2016)

#8
Sad to say I scored perfectly, due to a similar early disillusionment on embedded platforms, and years of pain porting code between 16- and 32-bit architectures when the author thought they knew the size of “int”.

Re: So you think you know C? (2016)

#9
My 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 led me to think: If the author was asking these questions, at least one or two questions must be answerable (even if it's technically incorrect, but you'd better to guess the original intention of a question). So I still tried to guess and got two wrong answers... Get to be careful next time...

Post reply on HN