c – atoi() – 字符串到int

我读到atoi()已被弃用,它相当于:

(int)strtol(token_start,(char **)NULL,10);

这是否意味着我应该使用上面而不是atoi(chr)或者它只是说它们是等价的?

解决方法

它确实在Apple的 Mac OS X Manual Page for atoi(3)(以及BSD手册页)中说过atoi已被弃用.

The atoi() function has been deprecated by strtol() and should not be
used in new code.

我会因为这个原因使用strtol()等效,但我怀疑你不得不担心atoi()被删除.

http://www.codecogs.com/library/computing/c/stdlib.h/atoi.php开始
实施说明

* The atoi function is not thread-safe and also not async-cancel safe.
* The atoi function has been deprecated by strtol and should not be used in new code.

相关文章

一.C语言中的static关键字 在C语言中,static可以用来修饰局...
浅谈C/C++中的指针和数组(二) 前面已经讨论了指针...
浅谈C/C++中的指针和数组(一)指针是C/C++...
从两个例子分析C语言的声明 在读《C专家编程》一书的第三章时...
C语言文件操作解析(一)在讨论C语言文件操作之前,先了解一下...
C语言文件操作解析(三) 在前面已经讨论了文件打开操作,下面...