This is not supposed to work, since fa is a fstream object it will never evaluate as false if i'm seeing things correctly. Even if it works, the advised way for checking if a file was correcly open in this case would be:

This is not supposed to work, since fa is a fstream object it will never evaluate as false if i'm seeing things correctly. Even if it works, the advised way for checking if a file was correcly open in this case would be:

Code:

if (!fa.is_open()) {}

This seems to work just fine. The function runs and changes the test1.bin file but doesn't change the test2.bin one.

I went throught the code, listing the values of the writed line of the test2.bin file and they are changed, but after the program closes (fa.close and fb.close) and i list the whole file the change is not there...