Any other way than using ofstream to write data to .txt files in C++ [closed]

StackOverflow https://stackoverflow.com/questions/14316327

  •  15-01-2022
  •  | 
  •  

Вопрос

I tried to use ofstream to write data to a .txt file in OMNET++ as follows with iostream and fstream included:

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

But OMNET++ is not resolving open and close functions.

Can someone suggest any way other than ofstream to achieve the same task of reading and writing data to .txt files in C++?

Это было полезно?

Решение

Turning my comment into an answer.

ofstream (and all other Standard Library classes) are defined in namespace std. You need to use qualified names (such as std::ofstream) to access them.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top