Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当使用参数 15 运行我的程序时,atoi 返回 1。 Atoi 只返回第一个数字。这应该发生吗?我该如何解决?
int _tmain(int argc, char* argv[]) { int a = atoi(argv[1]); }
从 _tmain 更改为 main 解决了这个问题。
它应该转换整个以 NUL 结尾的字符串:
#include <iostream> #include <stdlib.h> int main() { std::cout << atoi("15"); }
结果:
15