0

我尝试使用ofstream将数据写入 OMNET++ 中的 .txt 文件,如下iostream所示fstream

ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();

但是 OMNET++ 没有解析openclose功能。

ofstream除了在 C++ 中实现在 .txt 文件中读取和写入数据的相同任务之外,有人可以提出任何建议吗?

4

1 回答 1

4

将我的评论变成答案。

ofstream(以及所有其他标准库类)在 namespace 中定义std。您需要使用限定名称(例如std::ofstream)来访问它们。

于 2013-01-14T10:13:40.943 回答