I want to edit a textfile with multiple lines. In every line I want to remove the first character if it's a space.
I have found multiple examples with ifstream and ofstream. But there, input and output file are different files.
But I want input and output to be the same file but I can't figure out if and how fstream works.
fstream file;
file.open(path, ios::in | ios::out);
while (getline(file, line))
{
if (line[0] == ' ')
{
line.erase(0, 1);
}
file << line << "\n";
}
So far the code doesn't change anything in my file.
Thanks for for the help.