#include <iostream>
11 #include <string>
12 #include <cstdlib>
13
14 using namespace std;
15
16 int main() {
17 string s = "123";
18 double n = atof(s.c_str());
19 //int n = atoi(s.c_str());
20
21 cout << n << endl;
11 #include <string>
12 #include <cstdlib>
13
14 using namespace std;
15
16 int main() {
17 string s = "123";
18 double n = atof(s.c_str());
19 //int n = atoi(s.c_str());
20
21 cout << n << endl;
22 }
---摘自 http://www.cnblogs.com/oomusou/archive/2006/10/10/525647.html
本文介绍了C++编程中使用`atof`和`atoi`函数将字符串转换为浮点数的过程,并展示了如何通过`cout`输出转换后的数值。文章深入探讨了不同类型转换的区别及应用场景。
4693

被折叠的 条评论
为什么被折叠?



