<分区>
有人告诉我不应该使用 atoi()
,而且我应该始终使用 strtol()
反而。 atoi()
有什么问题我不应该使用它? strtol()
真的是正确的选择吗? (关于 strtol()
返回一个 long
而不是像 atoi()
那样的 int
的事实呢? ?)
标签 c
<分区>
有人告诉我不应该使用 atoi()
,而且我应该始终使用 strtol()
反而。 atoi()
有什么问题我不应该使用它? strtol()
真的是正确的选择吗? (关于 strtol()
返回一个 long
而不是像 atoi()
那样的 int
的事实呢? ?)
最佳答案
来自您自己的 link :
The atoi() function is subsumed by strtol() but is retained because it is used extensively in existing code. If the number is not known to be in range, strtol() should be used because atoi() is not required to perform any error checking.
或者
atoi
已过时
关于c - 为什么我不应该使用 atoi()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17710018/