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!

4
  • 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.) Commented Apr 5, 2020 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. Commented Apr 5, 2020 at 19:19
  • Possible duplicate of wostream fails to output wstring and/or Windows Unicode C++ Stream Output Failure? Commented Apr 5, 2020 at 19:46
  • Thanks @walnut The first link has helped! Commented Apr 5, 2020 at 20:32

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.