atol() v/s. strtol()

前端 未结 7 1807
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 19:13

What is the difference between atol() & strtol()?

According to their man pages, they seem to have the same effect as well as matching arguments:

         


        
7条回答
  •  被撕碎了的回忆
    2020-11-30 20:11

    atol(str) is equivalent to

    strtol(str, (char **)NULL, 10);
    

    Use strtol if you want the end pointer (to check whether there are more characters to read or if in fact you have read any at all) or a base other than 10. Otherwise, atol is fine.

提交回复
热议问题