So you think you know C? (2016)
241–250 of 344 posts
Re: So you think you know C? (2016)
#242I know that most of this stuff is undefined according to the spec. But I (might) also know what my particular GCC version does in these cases.
What I know for sure, that those programs do output something, and it's not "I don't know" (the string) ; )
What I don't know, is what level of sophistication the author assumes.
Re: So you think you know C? (2016)
#243Earlier quoted context omitted.
I couldn't agree more. After spending many years working with LLVM, which is at its heart a C compiler, and understanding why it has to do the sometimes-terrifying things it has to do to get C to run well, I've become very paranoid when writing C or C++. My C/C++ code is as boring as possible. (In fact I try to avoid writing C or C++ whenever possible these days; undefined behavior in the language is too pernicious a…
What would we write drivers in then if C was obsoleted?
Re: So you think you know C? (2016)
#244Earlier quoted context omitted.
To me "I don't know" is a very apt choice. It makes the point clear that indeed reading the code does not allow you to know the result, which is quite a pitfall. In your comment you are jumping from "I don't know", which is the first step, to wanting to explain why.
But the point is that I do know what that will print on my computer(s), with my compiler(s), on my architecture(s). "I don't know" is too generic a statement.
This is an article about the C language and the starting point with all the examples is that you do not know for a fact what the result will be.
Re: So you think you know C? (2016)
#245Earlier quoted context omitted.
Though different people consider different things simple. To one a loop is fine, to another a map is a better choice.
map/filter/reduce is simpler, but it takes some getting used to. Loops have worn a deep rut in my brain.
I don’t think I’ve ever written one correctly on first try.
Re: So you think you know C? (2016)
#246Earlier quoted context omitted.
To me "I don't know" is a very apt choice. It makes the point clear that indeed reading the code does not allow you to know the result, which is quite a pitfall. In your comment you are jumping from "I don't know", which is the first step, to wanting to explain why.
But the point is that I do know what that will print on my computer(s), with my compiler(s), on my architecture(s). "I don't know" is too generic a statement.
Re: So you think you know C? (2016)
#247Earlier quoted context omitted.
"I cant know" is a subset of "I dont know" "I dont know" was absolutely the correct answer.
Except from the perspective of a pragmatics linguistic analysis, "I don't know" has a social context of "There's an answer, and I don't know it." In this case, a non-C programmer should answer "I don't know" to all of them. A person with a passing familiarity should answer similarly. A seasoned pro would be forced to answer the same. Making it a rather useless tool for distinguishing people who think they know C but…
I don't think that assumption is justified. Someone could say the point of the exercise is to illustrate that C is confusing.
Re: So you think you know C? (2016)
#248Earlier quoted context omitted.
Each of the questions has exactly one answer that is correct regardless of version and platform.
It would be correct to answer that I don't have enough information to choose an option. It's incorrect to answer that I don't know.
Re: So you think you know C? (2016)
#249I failed on one, number 4. I bravely assumed 16 bit integers cannot exist. Can anyone name a concrete platform/compiler where int is/was 16 bit. Or is this just a theoretical option left open by the spec?
Re: So you think you know C? (2016)
#250There are a few problems with the questionnaire. "I don't know" is pretty generic choice to be given/choosen. Say for example, in question 5, the statement "return i++ + ++i;" is undefined, because the value of i is read and modified twice in a single sequence point (and of course, the order of addition is unspecified), which is not allowed in C. So the answer is "Undefined." (The explanation given in the page not ac…
To me "I don't know" is a very apt choice. It makes the point clear that indeed reading the code does not allow you to know the result, which is quite a pitfall. In your comment you are jumping from "I don't know", which is the first step, to wanting to explain why.
Using "I don't know" as a substitute for "I know that the standard clearly covers this, and it says that the result depends on the implementation" does seem to be designed to piss off people who know C. If they really wanted to get the point across that you don't know what is and isn't implementation defined or undefined, they shouldn't be using vague questions to mislead people; they should just plainly ask questions which people don't know the answer to.
I hate this kind of questioning where you 100% know the subject matter the quiz is asking about, but the question and possible choices is so vague you have to try to interpret what you suspect the person who wrote the quiz wants the answer to be. I once had an exam which was full of that kind of multiple choice question, and guessed the exam author's intentions wrong on most of them.