为什么会出现在stdlib.h中没有strtoi? [英] Why is there no strtoi in stdlib.h?
本文介绍了为什么会出现在stdlib.h中没有strtoi?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经习惯于的strtod
和变种。
我想知道为什么没有strtoi随stdlib.h中。
为什么该整数离开了这个派对的?
I have grown accustomed to strtod
and variants.
I am wondering why there is no strtoi shipped with stdlib.h.
Why is it that the integer is left out of this party?
具体我问为什么没有一个版本的atoi用的strtod的安全功能。
Specifically I am asking why there is not a version of atoi with the safety features of strtod.
推荐答案
与strtol()
字符串转换为整数,一个长整型但仍然一个整数。有的atoi()
,但在大多数情况下可避免由于缺乏对错误的无效输入报告机制的事实。
strtol()
converts a string to an integer, a long integer but an integer nevertheless. There is atoi()
but it should be avoided in most cases due to the fact it lacks a mechanism for error reporting from invalid input.
这篇关于为什么会出现在stdlib.h中没有strtoi?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文