Re: LPCTSTR to std::string

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"Jacky Luk" <jl@xxxxxxxxxx> wrote in message
news:uT4bsfI5GHA.2536@xxxxxxxxxxxxxxxxxxxxxxx
Hi
How to cast a LPCTSTR to std::string?
In this case it's not a "cast". It's an "assignment" or "copying"...

Do I just
m_fileName = lpszPathName;
This is the way to do it (it's called assignment)

or
strcpy (m_fileName, lpszPathName);
If you try this one it would give a compiler error, because you can't "cast"
an std:string to char* (only const char*)

or
there is something more useful?
What do you mean by useful? Easier? Faster? Funnier :)

--
Abdo Haji-Ali
Programmer
In|Framez


.



Relevant Pages

  • Re: LPCTSTR to std::string
    ... doesn't seem to work well in 16-bit characters (foreign characters), ... BOOL Cdecom7Doc::OnOpenDocument(LPCTSTR lpszPathName) ... This is the way to do it (it's called assignment) ... an std:string to char* ...
    (microsoft.public.vc.language)
  • Re: *str++ is undefined?
    ... But the act of actual assignment consists of one and only ... call in the destination object of type 'char'. ... char res = tolower; ... Or it can be evaluated in accordance with a different schedule ...
    (comp.lang.c)
  • Re: making bytes out of bits
    ... Since the compiler told you the code was broken, ... char a; ... schwartz2.c:17: warning: suggest parentheses around assignment used as ...
    (comp.lang.c)
  • Re: little endian or big endian ???
    ... char *cptr; ... printf; ... This most probably isn't a homework question. ... assignment. ...
    (comp.lang.c)
  • Re: making bytes out of bits
    ... Since the compiler told you the code was broken, ... char a; ... schwartz2.c:17: warning: suggest parentheses around assignment used as ...
    (comp.lang.c)