void readersWriters::WriteLine(int lineNumber, std::string newLine)
{
fstream file(_fileName, std::fstream::out | std::fstream::in);
if (file.is_open())
{
int count = 1;
string line_data;
bool found = false;
while (!file.eof() && !found)
{
getline(file, line_data);
if (count == lineNumber)
{
writeLock();
found = true;
if (line_data.length() > newLine.length())
newLine += line_data.substr(newLine.length(), line_data.length());
file << newLine;
getline(file, line_data);
writeUnlock();
}
count++;
}
file.close();
if (!found)
{
cout << ERROR_WRITE << endl;
}
}
}
I'm trying to write to the fstram file, the function run without any errors, but the file stay the same. I can't understand why it's happen :(. Thanks for the halp :)