与atoi() - 字符串为int [英] atoi() — string to int

查看:83
本文介绍了与atoi() - 字符串为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读的atoi()是德precated,它等同于:

I read that atoi() is deprecated and that it is equivalent to:

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

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

推荐答案

它不会对苹果的说,<一个href=\"https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man3/atoi.3.html\"相对=nofollow> Mac OS X的手册页的atoi(3)(和BSD手册页太)的的atoi 已去precated。

It does say on Apple's Mac OS X Manual Page for atoi(3) (and in the BSD man pages too) that atoi has been deprecated.

在与atoi()函数已被与strtol(pcated德$ P $),不应该
  在新的code使用。

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

我会使用与strtol()相当于只是出于这个原因,但我怀疑你不必担心的atoi()被删除。

I would use the strtol() equivalent just for that reason, but i doubt you have to worry about atoi() being removed.

<击>
HTTP://www.$c$ccogs。 COM /图书馆/计算机/ C / stdlib.h中/ atoi.ph​​p
实现说明

* 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.

这篇关于与atoi() - 字符串为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆