logging - C++ wstring to file instead of string -


i have simple logger class tried turn accepting , outputting wstrings instead strings.

header:

#include <fstream> using namespace std;  class clog  {   public:     clog(wstring filename);     ~clog();     void writestring(string ustring);   private:     fstream m_stream; }; 

cpp:

#include "stdafx.h"; #include "log.h";  clog::clog(wstring upath)  {   m_stream.open(upath); } void clog::writestring(string ustring) {   m_stream << ustring.c_str() << endl; } clog::~clog() {   m_stream.close(); } 

can suggest should use instead of fstream? tried using wstringstream, did not have .open output file, thought wrong approach.

i keep behaviour writes file.

i use "wofstream" instead of "fstream" now, , works perfectly.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -