C++ 字符串 与 整数、浮点数的相互转换

整数、浮点数转字符串

std::to_string

定义于头文件 `[](https://zh.cppreference.com/w/cpp/header/string)`
[std::string](http://zh.cppreference.com/w/cpp/string/basic_string) to_string(int value); (1) (C++11 起)
[std::string](http://zh.cppreference.com/w/cpp/string/basic_string) to_string(long value); (2) (C++11 起)
[std::string](http://zh.cppreference.com/w/cpp/string/basic_string) to_string(longlong value); (3) (C++11 起)
[std::string](http://zh.cppreference.com/w/cpp/string/basic_string) to_string(unsigned value); (4) (C++11 起)
[std::string](http://zh.cppreference.com/w/cpp/string/basic_string) to_string(unsignedlong value); (5) (C++11 起)
[std::string](http://zh.cppreference.com/w/cpp/string/basic_string) to_string(unsignedlonglong value); (6) (C++11 起)
[std::string](http://zh.cppreference.com/w/cpp/string/basic_string) to_string(float value); (7) (C++11 起)
[std::string](http://zh.cppreference.com/w/cpp/string/basic_string) to_string(double value); (8) (C++11 起)
[std::string](http://zh.cppreference.com/w/cpp/string/basic_string) to_string(longdouble value); (9) (C++11 起)

定义于头文件 [<string>](https://zh.cppreference.com/w/cpp/header/string)<br></br>

[stoulstoull](https://zh.cppreference.com/w/cpp/string/basic_string/stoul)(C++11)(C++11) 转换字符串为无符号整数

(函数)
[stoistolstoll](https://zh.cppreference.com/w/cpp/string/basic_string/stol)(C++11)(C++11)(C++11) 转换字符串为有符号整数

(函数)
[stofstodstold](https://zh.cppreference.com/w/cpp/string/basic_string/stof)(C++11)(C++11)(C++11) 转换字符串为浮点值

(函数)

原文链接: https://www.cnblogs.com/0patrick/p/14167417.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/206319

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月12日 下午10:33
下一篇 2023年2月12日 下午10:33

相关推荐