问题标签 [atoi]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
6 回答
133391 浏览

c - sscanf 或 atoi 将字符串转换为整数有什么区别?

gcc 4.4.4 c89

将字符串转换为整数值更好。

我尝试了 2 种不同的方法 atoi 和 sscanf。两者都按预期工作。

或使用 atoi

我在想 sscanf 会更好,因为你可以检查错误。但是,atoi 不做任何检查。

0 投票
9 回答
32416 浏览

c - 在调用 atoi() 之前如何检查以确保您有一个整数?

我希望将整数作为命令行参数,但如果用户传递一个非整数字符串,这将导致堆栈溢出。确保 atoi() 成功的标准方法是什么?

0 投票
3 回答
19330 浏览

c - 为什么 atoi 给我一个分段错误?

我有以下代码:

所以,我通过这个程序是这样的:

而不是得到预期的输出

1
2

我得到一个分段错误。是什么赋予了?

0 投票
6 回答
3884 浏览

atoi - 在 C 中使用 atoi() 函数

我想将字符串转换为整数。但我的字符串是 234,23,34,45。如果我使用 atoi,它只给我 234。我想转换我的字符串中的所有整数。我如何使用 atoi 来解决这个问题或什么可以我用代替atoi??

0 投票
10 回答
11865 浏览

c - atoi 和前导 0 用于十进制数

在 CI 中使用atoi时,我试图将char数字数组转换为int. 不过,我的号码上有前导0,当我稍后打印号码时,它们不会被保留。

这个输出将是905607,我希望它是00905607

有任何想法吗?

0 投票
11 回答
26994 浏览

c++ - 喜欢 atoi 但要漂浮

是否有类似于 atoi 的函数将字符串转换为浮点数而不是整数?

0 投票
2 回答
6349 浏览

c - c atoi() 用于 Linux 上的宽字符?

Linux 上的宽字符是否有 ac atoi() 等效项?我可以为 MS (wtoi) 找到一些东西,但我可以在标准 Linux 库中找到任何东西。

0 投票
5 回答
174 浏览

c++ - Why is this IO operation looping infinitely?

I am trying to read from a text file and tokenize the input. I was getting a segmentation fault until I realized I forgot to close my ifstream. I added the close call and now it loops infinitely. I'm just trying to learn how to use strtok for now, that is why the code doesn't really look complete.

p>

input file:(one line)

5 +8 0 0 25

0 投票
1 回答
1173 浏览

c++ - C++ - 使用 atoi() 时未处理的异常

使用此代码时,它会引发未处理的写入异常,我几乎可以肯定这与 atoi() 函数有关。

0 投票
4 回答
6952 浏览

c - 将字符数组转换为C中的整数数组

我将参数传递给 C 程序:

程序名称 1234

我希望能够将传递给函数的参数的每个数字单独用作整数。atoi(input[]) 引发编译时错误。

此代码无法编译: