newbie question reguarding safe practice of file io
what im wondering about is can I read files, without worrying about destroying data?
Below is a snippet out of tutorial 10 file io, it says I have too be careful of destroying data, does this account for any type of stream? or is it just input stream that writes too the file?
Quote:
This will open the file without destroying the current contents and allow you to append new data. When opening files, be very careful not to use them if the file could not be opened. This can be tested for very easily:
Code:
ifstream a_file ( "example.txt" );
if ( !a_file.is_open() ) {
// The file could not be opened
}
else {
// Safely use the file stream
}