Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the given function differs from the statement'errno is not neccessarily set on conversion error'?

  • A.atof()
  • B.atoi()
  • C.atol()
  • D.strtod()

Answer: D

Correct answer: strtod()

strtod is the one that does report the error: on overflow or underflow it sets errno to ERANGE, and it also returns a pointer to the first character it could not convert. atof, atoi and atol simply return 0 on failure, which is indistinguishable from a legitimate 0 - which is why the strto family should be used in real code.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.