gpt4 book ai didi

c++ - C++中是否推荐使用cstdio、cstring、cmath等?

转载 作者:可可西里 更新时间:2023-11-01 15:42:13 26 4
gpt4 key购买 nike

在c++中是否推荐使用cstdio、cstring、cmath?我正在编写一个需要 pow 、 strlen 和 sprintf 的程序……为此,我唯一能做的就是包含这 3 个 header 。有更好的 C++ 方法吗?

谢谢

最佳答案

您可以使用 std::stringstream 代替 sprintfstd::string 代替 C 风格的字符串。但是 C++ 只是将 C 库用于数学函数。

C++ 为数学函数添加了一些方便的重载(例如,您可以将 exp() 用于 float 。)它们在 中可用,但不仅在 中可用。

关于c++ - C++中是否推荐使用cstdio、cstring、cmath等?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2488916/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com