by david-given · 10y ago · 0 comments
The reasoning is: the code as written makes no sense; therefore it's incomplete. Obviously, then, it's not intended to be read literally, and is just an abbreviated portion of the real code. The first line just declares p as a pointer. The second line dereferences the pointer. The pointer assignment has been elided for brevity and is not relevant to this question.
That's an expectation impedance mismatch. I'm expecting you to want a high level description of how pointers work. You're expecting me to provide a blow-by-blow machine level breakdown of the instructions involved.
(Also, the blank line enforced by HN between paragraphs really doesn't help here.)
No. The pointer assignment has been elided to see if anyone clues in that the pointer is, in fact, uninitialized.
The correct answer is "the pointer is uninitialized. Writing to it will result in undefined behavior, possibly even a SEGV."
No, it's not omitted for the sake of brevity. The point is that if you can't find bugs in trivial code, you shouldn't call yourself a C programmer.