Why is there no strtoi in stdlib.h?

后端 未结 6 1999
深忆病人
深忆病人 2020-11-27 16:34

I have grown accustomed to strtod and variants. I am wondering why there is no strtoi shipped with stdlib.h. Why is it that the integer is left out of this part

6条回答
  •  自闭症患者
    2020-11-27 16:46

    strtol() converts a string to an integer, a long integer but an integer nevertheless. There is atoi() but it should be avoided in most cases due to the fact that it lacks a mechanism for error reporting from invalid input.

提交回复
热议问题