NO

Author Topic: _wmakepath returns incorrect result  (Read 2508 times)

Offline sgraffe

  • Member
  • *
  • Posts: 20
_wmakepath returns incorrect result
« on: June 20, 2017, 03:06:28 PM »
Hello All:
I am not getting correct result from function _wmakepath. The following program demonstrate output from functions _makepath and _wmakepath.
Code: [Select]
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
   char path [FILENAME_MAX];
   char drive[] = "C:";
   char dir  [] = "\\foldername\\";
   char name [] = "filename";
   char ext  [] = "txt";

   _makepath(path, drive, dir, name, ext);
   printf("%s \n", path);

   wchar_t wpath [FILENAME_MAX];
   wchar_t wdrive[] = L"C:";
   wchar_t wdir  [] = L"\\foldername\\";
   wchar_t wname [] = L"filename";
   wchar_t wext  [] = L"txt";

   _wmakepath(wpath, wdrive, wdir, wname, wext);
   printf("%ls \n", wpath);

   return 0;
}
Output:
C:\foldername\filename.txt    (from _makepath)
C:\foldername\                       (from _wmakepath)

Output from _wmakepath is missing the filename and extension components.
Compiler options are: -std:C11 -Tx86-coff -Ot -Ob1 -fp:precise -W1 -Gd -Zx
Version: 8.00.60 (Win64)

TimoVJL produced a fix for this bug in
http://forum.pellesc.de/index.php?topic=7162.msg27173#msg27173
Regards,