C++,关于fprintf和ofstream

are*_*esz 5 c++ printf ofstream

我已经使用fprintf了一段时间了,我想问一个问题.这条fprintf线的等价物是什么:

fprintf(OutputFile, "%s", "SomeStringValue");
Run Code Online (Sandbox Code Playgroud)

ofstream

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

UpA*_*dam 3

你不使用它。

本质上等价的是:

std::ofstream x("your_file");
x << "SomeStringValue";
x.close();
Run Code Online (Sandbox Code Playgroud)

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