0

I'm new in C++ and for practicing puprose I wanted to write a program that can read Romanji and write it back in Hiragana.

Everything work's except for writing it in the file. I use "wofstream" and "wstring" for saving japanese characters.

When the program is done, the file is completly empty and 0kb big, so it has nothing written in.

std::wofstream out;
out.open(JaRoConverter::txt);

std::wstring cache;
cache = ConvertRoToJa();
out << cache;

out.close();

In the debugger of vs2019 is in "cache" everything correct! But in the next line, nothing happens..

I don't understand the problem.. I'm grateful for any help!

EDIT: Thanks to walnut the probleme is solved!

Traijan
  • 73
  • 1
  • 8
  • 1
    Obvious questions first: Do you check that the file was opened successfully? Do you check that the write is successful? Is the file that you opened actually the same file that you look into later? (Maybe delete it before running the program to verify it.) – walnut Apr 05 '20 at 19:03
  • Yes, the file is definetly the correct. 1) When writing in it (on my own) and using the program, the previous text is gone 2) When writing something else than japanese letters it's in the file. – Traijan Apr 05 '20 at 19:19
  • Possible duplicate of [wostream fails to output wstring](https://stackoverflow.com/questions/11610583/wostream-fails-to-output-wstring) and/or [Windows Unicode C++ Stream Output Failure](https://stackoverflow.com/questions/9859020/windows-unicode-c-stream-output-failure)? – walnut Apr 05 '20 at 19:46
  • Thanks @walnut The first link has helped! – Traijan Apr 05 '20 at 20:32

0 Answers0