jeudi 23 février 2017

Is the default mode of ofstream implementation defined?

Given the following code:

std::ofstream stream("somefile");

if (!stream)
{
   return 1;
}

When invoking .write(....) and using stdc++ and libc++ the stream is in binary mode (std::ios::binary).

However when using MSVC (2015/2017RC1) it seems to be in text mode or something weird, because the the resulting file is larger than what is actually written.

But if i explicitly set the mode std::ios::binary MSVC behaves similarly to the std::ofstream implementations of other standard libraries mentioned earlier.

Aucun commentaire:

Enregistrer un commentaire