c++ - fwprintf is printing out garbage -


I have a program that receives a list of directories (selected by the user) and list the related directories and files While printing the file in that directory, it is always a '?' Then prints a random character after that. I am working on WinAPi, Visual C ++ 2010 Express I am using Unicode (hence I am using extensive characters). I am guessing my problem that it is in the phf printf function that I am using because it adds the directory / files in my std :: list which is right to me. This is my current task:

  list for std :: list & lt; Std :: wstring & gt; LDirectories; Zero Cleanup Contents (Constwchar_t * sDir) {List Directory Content (SDIR) // function that adds each file and directory to the std :: list wchar_t dir [MAX_PATH * 10]; Wsprintf (DIR, L "% s \\ listoff files and directories.t.tt.", SDIR); FILE * pFile; Errno_t err = _wfopen_s (and Pfile, DIR, L "W"); While (! LDirectories.empty ()) {fwprintf (Pfile, L "% s", lDirectories.front ()); LDirectories.pop_front (); } Err = fclose (pFile); }  

The problem is in this line:

  FF print (Pfile, L "% s", lDirectories.front ());  

fwprintf is expected to be wchar_t * and you provide wstring . Change to

:

  fwprintf (pFile, l "% s", lDirectories.front () .c_str ());  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -