ok, i need small help, to create/open a file with specific name, in order to make it clear here's a small function from my program

void CreateNew () 
{
     string fileName = "helpme.txt"; //==>>> my problem!!
     ofstream DataFile;
    DataFile.open(fileName, ios::out | ios::app); // string fileName == filename 
     if (DataFile.is_open())
     {
                          cout<<"Yeah, created"<<endl;
                          cout<<"Filename: "<<fileName<<endl;
     }
     else
     {
         cout<<"Call cops!"<<endl;
     }
     DataFile.close(); //flush 
}

Thank you!

>DataFile.open(fileName, ios::out | ios::app);

DataFile.open(fileName.c_str(), ios::out | ios::app);

The open member function takes a C-style string.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.