Can't create std::ofstream variable despite including <iostream>
c++, fstream, iostream
Solution
You can try this:
#include <fstream>
int main () {
std::ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
Problem
I am getting an ofstream error in C++, here is my code ``` #include <iostream> int main() { std::ofstream myfile; myfile.open("example.txt"); myfile << "Writing this to a file.\n"; myfile.close(); return 0; } ``` error from Dev-C++ 10 C:\devp\main.cpp aggregate `std::ofstream OutStream' has incomplete type and cannot be defined