karthik
karthik

Reputation: 17842

How to initialize wchar_t pointer variable in c++?

I like to know how to initialize and how to copy the contents of one wchar_t* variable into another wchar_t* variable.

    wchar_t *lfFace = new wchar_t;
    dc.GetTextFaceW(LF_FACESIZE,lfFace);

This sample will throw runtime error.Please correct these.

Thnks

Upvotes: 1

Views: 1730

Answers (2)

Kaz Dragon
Kaz Dragon

Reputation: 6809

According to MSDN, you'll want something like this:

wchar_t *lfFace = new wchar_t[LF_FACESIZE];
dc.GetTextFaceW(LF_FACESIZE, lfFace);
// do stuff with lfFace
delete [] lfFace;

Upvotes: 1

tenfour
tenfour

Reputation: 36896

Use CStringW instead. Like this:

CStringW faceName;
dc.GetTextFaceW(faceName);

Upvotes: 4

Related Questions