My code is here:
//wstring filename = temp.name + L".txt"; wstring filename = L"hero2.txt"; //wofstream File(filename.c_str()); wofstream outputFile(L"temp.txt", ios::ate | ios::binary); if (outputFile.fail()) windowmsg(1, LPCWSTR(L"Could not Save game")); else windowmsg(1, LPCWSTR(L"Game Saved")); wchar_t BOM = 0xFEFF;//Byte Order Mark character outputFile << BOM; outputFile << temp.name << endl; outputFile << temp.lvl << endl; outputFile << temp.HP <<endl; outputFile << temp.minHP <<endl; outputFile << temp.MP <<endl; outputFile << temp.minMP <<endl; outputFile << temp.ATK <<endl; outputFile << temp.DEF <<endl; outputFile << temp.mATK <<endl; outputFile << temp.mDEF <<endl; outputFile << temp.SPD <<endl; outputFile << temp.exp <<endl; outputFile << temp.exptonext <<endl; outputFile << temp.gearnumber <<endl; for (int count = 0 ; count < temp.gearnumber ; count++) { outputFile << temp.equip[count].name <<endl; outputFile << temp.equip[count].type <<endl; outputFile << temp.equip[count].ATK <<endl; outputFile << temp.equip[count].DEF <<endl; outputFile << temp.equip[count].mATK <<endl; outputFile << temp.equip[count].mDEF <<endl; outputFile << temp.equip[count].SPD <<endl; } I have tried many things, I can't remember them all to state them here. Such as changing the second parameter in fstream to ios::ate | ios::binary and such. I tried converting the empty text file to UTF, with and without BOM, I tried writing the BOM in the C++ code before writing any variables. I always just get a blank file.
Project encoding is Unicode character set. As a note, I really don't care what encoding the file will be, I will only be writing English character text to it. So as long as it writes the file I'm happy.
outputFile .flush()? You can also try closing the stream before checking for data in the file...std::setlocale(LC_ALL, "")as the first thing in your program (NOTstd::locale::global(anything)).