Is this correct, it works OK
string str("in.dat");
ifstream fin(str.c_str(), ios::binary | ios::ate );
.
.
.
//Do I need to clear the string before assigning new name???
str = "out.dat";
ofstream fout(str.c_str(), ios::binary); //seems to work
Regards
What you did is correct. The = operator will overwrite string contents, it's normal scenario of reusing string variable. It will even probably not realloc any buffer, but reuse existing instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With