I am doing a program to change the parameter file. Here I have to read a text file. Search for appropriate parameter and replace it. The modified parameter contains and unchanged are kept in buffer. Now i have to write this data in same file i using to read. I face problem while writing buffer data to file. It throws file can't open exception.
// look for key and update it's value . if key not found then add it with value.
void OEUpdater::update(const std::string& key, const std::string& value)
{
std::string replace = key + ": " + value + "\n";
std::string cur_line;
std::string file_content ;
bool found = false;
// key value search and replace part //
src.close();
// reopen file with truncation
fstream tgt;