gpt4 book ai didi

C++,关于 fprintf 和 ofstream

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:25:09 24 4
gpt4 key购买 nike

我已经使用 fprintf 一段时间了,我想问一个问题。此 fprintf 行的等价物是什么:

fprintf(OutputFile, "%s", "SomeStringValue");

使用ofstream ?

如何在 ofstream 中使用“%s”是我真正想知道的。如何获取下一个参数并将其打印为字符串?

最佳答案

你不使用它。

本质上等价于:

std::ofstream x("your_file");
x << "SomeStringValue";
x.close();

在几个引用页面中的任何一个上阅读它。如http://www.cplusplus.com/reference/ostream/ostream/operator%3C%3C/

关于C++,关于 fprintf 和 ofstream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18263461/

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