General wide char LPWSTR help

  • Thread starter Thread starter DanMP
  • Start date Start date
D

DanMP

Guest



I'm understanding that there are two main types of data in C++ these days- ANSI - also called multiple bytes / and Wide. Is this correct?

LPWSTR - is a Long Pointer to Wide string... I think.

wchar_t is a wide string?

This is my very simple beginning of a program... What am I doing wrong?

Data Declarations, in header file:

LPWSTR mc_buffer[(MAX_PATH * MAX_PATH)]; -- was initialized here... but didn't compile.
LPWSTR mc_OutBuff[100] = { L"" };
LPWSTR outl[100] = { L"" };



The following .cpp code compiles, but doesn't work...


LPWSTR hi[4];
wcscat((wchar_t*)&hi, _T("Hi"));
wcscat((wchar_t*)&mc_buffer, (const wchar_t*)hi);



The code ran up to the first wcscat. There is a breakpoint at the second wcscat... It is stopped there... -This is a fresh new project created in Visual Studio 2017, Windows 7. The Project property- All configurations | Platform: Win32 | General | Project Defaults | Character Set - is set to Unicode.

These are the messages in the Autos section in the debug session ..


+ wcscat returned 0x0122ee2c wchar_t *

+ &hi
0x001ceb24 {0xcccccccc <Error reading characters of string.>, 0xcccccccc <Error reading characters of string.>, ...}
wchar_t *[4] *

+ &mc_buffer
0x0117a00c {0x003a0053 L"", 0x00470000 L"", 0x006f006c L"쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌쳌...,
...} wchar_t *[67600] *

+ hi
0x001ceb24 {0xcccccccc <Error reading characters of string.>, 0xcccccccc <Error reading characters of string.>, ...}
wchar_t *[4]





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Trying:

wcscat((wchar_t*)hi, L"Hi");

-Will compile.. but doesn't work. In debug, there is the same "error reading characters of string" message.


Trying:

wcscat(hi, L"Hi");

-Will not compile.

-msgs are:

Error
C2664 'wchar_t *wcscat(wchar_t *,const wchar_t *)': cannot convert argument 1 from 'LPWSTR [4]' to 'wchar_t *'

Error (active)
E0167 argument of type "LPWSTR *" is incompatible with parameter of type "wchar_t *"

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What am I doing wrong? Thank You for any help.


used: Dos, MSDos, Win3, Win95, WinXP, Vista, Win7, and Win8 || AIX/Linux, etc: HP AIX, IBM AIX, Ubuntu, OpenSUSE, Puppy Linux, OS/2, VM/CMS, SAP

Continue reading...
 
Back
Top