问题描述
出于好奇-当atoi函数将字符转换为整数,即转换为其数字表示形式,换句话说转换为其ASCII值时,为什么函数名atoi(将ASCII转换为整数)?
函数悖论的名称不是吗?
谢谢
Harish
Hi,
Just out of curiosity - When the function atoi is converting character to integer i.e. to its numerical representation, in other words to its ASCII value, why is the function name atoi (ASCII to integer)?
Isn’t the name of function paradox?
Thank you,
Harish
推荐答案
int atoi ( const char * str );
并查看其文档: http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/ [ ^ ].
严格来说,它甚至不转换任何内容.假设该字符串是代表整数值的字符串,它会尝试解析以空值结尾的字符串,然后返回该值.
and also see its documentation: http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/[^].
It does not even convert anything, strictly speaking. It attempts to parse a null-terminated string assuming this is a string representing integer value and returns this value.
这篇关于函数名称atoi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!