I had this Reopen audit, and I voted to reopen, and this was wrong!

Can someone please explain to me the following piece of code?

while(scanf("%d%d\n", p, q) == 2)

Is this really too broad? Why?

  • 4
    For one, it depends on what p and q are, which we don't know. In addition, the question title seem to focus on the meaning of the == operator, and if we have to start explaining what the == operator is and does in C we'll be here all day. Jul 14, 2014 at 8:13
  • 2
    @FrédéricHamidi I feel like this code is 100% clear. p and q are two integer pointer. And to explain what this code does is really not too long of an answer, if we'd focus on the basics and linked to the deeper subjects.
    – Theolodis
    Jul 14, 2014 at 8:17
  • 7
    @Theolodis, p and q are two integer pointer. Really? How do you know that? More importantly, what would it mean for your answer if they aren't? Jul 14, 2014 at 8:20
  • @Fr&#233;d&#233;ricHamidi the asker did obviously not ask why his code wasn't working, so i guess that it would be safe to make the assumption that his code was working.
    – Theolodis
    Jul 14, 2014 at 8:21
  • @FrédéricHamidi When i read the question the first think i think of is the beghaviour of the scanf-Function, specially the returning value. I think such a question is very normal, if i would face such a code i wouldnt understand i would have asked the same. Anyway the question here is it realy a good question to use as an audit? Jul 14, 2014 at 8:42
  • 3
    What do they want explained? while? scanf? "%d%d\n"? ==? Their combination? Something else? --> too broad
    – Roland
    Jul 14, 2014 at 8:42
  • @Roland: How about aqnswering with "As long as i read two parameters from stdin do something". Besides its not closed regarding unclear question! Jul 14, 2014 at 8:46
  • @CloudyMarble, I think it makes a good audit, yes. Even if the question is read as what does scanf() return?, it is readily answerable by reading the documentation. Otherwise, there are too many unknowns: what if p and q are not pointers? What if they're not pointers to signed int? What if they're pointers to unsigned int? signed long? double? What if p == q? And so on and so forth. Jul 14, 2014 at 8:46

1 Answer 1


There are at least three possible separate items on that line that could be "explained"; arguably more, depending on how far you want to delve into details. Virtually all "here is code, please explain" questions are too broad. We have no idea what the OP wants to know exactly or what they're confused about. Do they not understand what the code does logically? Do they not understand one specific operation within this code? Do they want to know how exactly the code gets to the result it does? If so, in how much detail? Is it enough to cite the manual definition of what the involved functions do, or does the OP want to know about behind-the-scenes pointers and memory allocation? Should we be enumerating all possible cases in which this code may fail or educate the OP about edge-cases in general? Is there any specific operator or function they don't understand? Have they consulted the manual, and possibly not understood what the manual tells them? Does that mean we need to regurgitate the manual in simpler terms? Do they expect an introductory course to the language syntax?

Such questions really generate more questions than anyone can answer. If the OP doesn't understand what a piece of code does, they need to clearly tell us what they do understand and what exactly they don't understand and to what level of detail they require an answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .