Io verificherei il valore restituito dalla fopen.
Amaro C++, il gusto pieno dell'undefined behavior.
Regole del Forum