LPCSTR
-
I have a difficulty... when I want to make a LPCSTR variable, I do this: LPCSTR test = TEXT ("hello"); Now I want to make a LPCSTR,including "hello" + name of a persion, which changes every time. I can't do below: CString name = "John"; LPCSTR test = TEXT ("hello" + name); or CString name = "John"; name = "hello" + name LPCSTR test = TEXT (name); please tell me how to do to achieve that result, or show me some pages related to changes of LPCSTR.
-
I have a difficulty... when I want to make a LPCSTR variable, I do this: LPCSTR test = TEXT ("hello"); Now I want to make a LPCSTR,including "hello" + name of a persion, which changes every time. I can't do below: CString name = "John"; LPCSTR test = TEXT ("hello" + name); or CString name = "John"; name = "hello" + name LPCSTR test = TEXT (name); please tell me how to do to achieve that result, or show me some pages related to changes of LPCSTR.
vtalau wrote:
CString name = "John"; LPCSTR test = TEXT ("hello" + name);
This should not be done. Always use
TCHAR
types withTEXT
and_T
, else when you compile with_UNICODE
defined it could lead to waste of time. You can do likewise...CString name = _T( "Nibu " );
name += _T( "Hello" );
LPCTSTR test = name;There is no need to wrap
name
insideTEXT()
. You should be careful when using statements likeLPCSTR test = name; // This will be fine till you do a unicode build.
So always adopt a generic approach. Try to use
_T()
orTEXT()
wherever possible along with their counterparts likeLPCTSTR
.
Nibu thomas A Developer Programming tips[^] My site[^]
-
I have a difficulty... when I want to make a LPCSTR variable, I do this: LPCSTR test = TEXT ("hello"); Now I want to make a LPCSTR,including "hello" + name of a persion, which changes every time. I can't do below: CString name = "John"; LPCSTR test = TEXT ("hello" + name); or CString name = "John"; name = "hello" + name LPCSTR test = TEXT (name); please tell me how to do to achieve that result, or show me some pages related to changes of LPCSTR.
-
vtalau wrote:
CString name = "John"; LPCSTR test = TEXT ("hello" + name);
This should not be done. Always use
TCHAR
types withTEXT
and_T
, else when you compile with_UNICODE
defined it could lead to waste of time. You can do likewise...CString name = _T( "Nibu " );
name += _T( "Hello" );
LPCTSTR test = name;There is no need to wrap
name
insideTEXT()
. You should be careful when using statements likeLPCSTR test = name; // This will be fine till you do a unicode build.
So always adopt a generic approach. Try to use
_T()
orTEXT()
wherever possible along with their counterparts likeLPCTSTR
.
Nibu thomas A Developer Programming tips[^] My site[^]
-
Nibu babu thomas wrote:
name += _T( "Hello" );
Just a detail, but this should be
name = L("Hello")+name;
otherwise: "Nibu Hello" :rolleyes:
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus