I am practicing for reading in a file and editing the contents. The input would be something like:
2 2 3 -1
3 3 -1 3
I want to make the -1's nothing. It works for the first line so I get:
2 2 3
3 3 -1 3
But as you can see, on other lines it does not edit. What is wrong with my loop? I am new to C++ so I am confused. Also, english is not my first language so sorry for any mistakes!
if (fin.is_open())
{
while ( getline (fin,line) )
{
for (int i; i<line.size(); i++){
if(line[i] == '-'){
line[i] = ' ';
line[i+1] = ' ';
}
}
cout << line << '\n';
}
fin.close();
}