Sign in to follow this  

const char* TO BOOL LPCTSTR

This topic is 3737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i need the method below to read a file,in generally,lpszPathName give the name or the path of the file,but how to convert this in const char*? BOOL COpenGLFrameDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; return true; }

Share this post


Link to post
Share on other sites
LPCTSTR is short (or cryptic) for Long Pointer Constant T-String. A T-string is an array of TCHAR which in turn is "char" or "wchar_t" depending on whether unicode is enabled or not in your project as ToohrVyk pointed out.

There is also LPTSTR (long pointer to non-constant T-string) LPSTR (ansi string), LPCSTR (constant ansi string), LPWSTR (wide-char, or wchar_t, string) and LPCWSTR (constant wide-char string).

Share this post


Link to post
Share on other sites
Yeah,can you give me an example to illustrat this.

i have a class and its method is READFILE(const char* path),and i need the lpszPathName must be convert in char*,so how to do this?
please in example
BOOL COpenGLFrameDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;

//conver it into const char*
//
//const char* path = ?????

myclass.READFILE(path);
return true;
}

Share this post


Link to post
Share on other sites
Assuming you're not using unicode character arrays, lpszPathName ___IS___ of type "const char *"

BOOL COpenGLFrameDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;

myclass.READFILE(lpszPathName);
return true;
}


Now please, some people made the effort to reply, so make the effort to understand what they replied instead of waiting to be fed with some code to copy and paste into your application. Everything you needed to fix your issue was ToohrVyk's reply, #1 right after your post.

/me just wasted 5 minutes of his life.

Share this post


Link to post
Share on other sites

This topic is 3737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this