How do I get a substring of a LPCTSTR?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
LPCSTRis just fancy name forchar *, it doesn’t have methods.If you use
std::stringyou could use thefindandsubstrmethods to extract the first and second part of the string.Edit: As noted by Christoph, the type of
TCHARdiffers depending on ifUNICODEis defined or not. IfUNICODEis defined (check with#ifdef UNICODE, do a Google search on preprocessor to learn more about things like#defineand#ifdef) you need to usestd::wstringinstead ofstd::string.Edit 2: An easier solution than checking if you need to use
std::stringorstd::wstringall the time, is to follow the advice of Konrad Rudolph and create a new typedef similar tostd::stringandstd::wstring. Something like this:And then use that string type internally.