c++ - std::wofstream failing to write long long -
i have 2 streams, 1 read , 1 write (diff. files). std::wofstream origin; std::wifstream attach; origin.open(m_sourcefile, std::ios_base::app | std::ios_base::binary); attach.open(csattachfilename, std::ios_base::in | std::ios_base::binary); appending data file works fine, until gets write operation std::streamoff variable. taking account std::wofstream , output variable "normally" did few times in function. //[...] origin.seekp(0, std::ios_base::end); //go end std::streamoff noffset = origin.tellp(); //int nfilenamelength = ...; origin.write(reinterpret_cast<wchar_t*>(&nfilenamelength), sizeof(nfilenamelength) / sizeof(wchar_t)); //int //nothing wrong here //[...] write more attach.close(); auto c1 = origin.bad(); //false origin.write(reinterpret_cast<wchar_t*>(&noffset), sizeof(noffset) / sizeof(wchar_t)); auto c2 = origin.bad(); //true //[...] write more what cause issue ? note works fine if use std::ofstream instead.