Search code examples
c++outputofstream

Ofstream rejects input with parameters


i am working for school project and i have to write some lines to a txt file. Nothing unusual but here comes the problem. When i try to input output file name through parameters in function it says that there is no matching function for call. Let me show you my code:

bool save(vector<City*> city, string output){
   ofstream dat(output); // ... here comes the problem
}  

I would be very happy if someone would know what is problem here and how to make it work. Thanks


Solution

  • You have either to enable the -std=c++11 compiler option, or use ofstream dat(output.c_str());

    See the reference documentation of the available std::ofstream constuctors.