开发者

What is the output destination of ofstream?

In the following C++ function:

void save_data(std::ofstream& csv) {
    csv << "a message";
}

Something I don't understand: if save_data is called, where开发者_JS百科 does it write to? To a file? How exactly is it used?


An ofstream represents a file on the file system:

int main()
{
    ofstream  file("Plop.txt");

    save_data(file);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜