I'm using a statement like
TCHAR path="";
wcscpy(path,_T("C:\\Users\\user\\Desktop\\Filename.ext"));
But its getting copied with spaces inbetween every character.How can i prevent it?
I'm using a statement like
TCHAR path="";
wcscpy(path,_T("C:\\Users\\user\\Desktop\\Filename.ext"));
But its getting copied with spaces inbetween every character.How can i prevent it?
You are NOT seeing spaces in between the characters.
wchar_t
is 2 bytes on Windows (4 bytes on other platforms). If you wish to use it to hold any ASCII character (ie: characters 0-127, which only require 1 byte), you will see that the first byte holds the character value and the additional bytes hold NULL bytes, since we only need 1 byte to hold the value (or 7 bits, to be more precise). If you are looking at the string data as 8bit instead of 16bit/32bit, those NULLs will appear as spaces.
If you do not want this, use the char
type instead.
On Windows, it is recommended to use wchar_t
and std::wstring
instead of char
and std::string
, especially when using the Win32 API since it will convert multi-byte strings to wide strings anyway.