If I directly using ios::out
to open a file, then it will overwrite it or modify it if the file was existed.
But if I check if there is a file named "XXX" with ios::in
, and create it with ios::out
if it's not exist, the file "XXX" may be created by another program during this period, then the file "XXX" will be overwrote or be modified just like the first case.
How can I safely create a file with fstream
in C++?
Aucun commentaire:
Enregistrer un commentaire