How do I make sure that strtol() have returned successfully?

后端 未结 4 1184
天涯浪人
天涯浪人 2020-12-31 07:18

according documentation:

On success, the function returns the converted integral number as a long int value. If no valid conversion could be perfor

4条回答
  •  庸人自扰
    2020-12-31 07:35

    IMHO, I prefer sscanf() to atoi() or strtol(). The main reason is that you cannot reliably check for error status on some platforms (i.e. Windows) unless you use sscanf() (which returns 1 if you succeed, and 0 if you fail).

提交回复
热议问题