?
Solved

Conversion of LPTSTR to LPCTSTR

Posted on 1999-12-17
3
Medium Priority
?
1,406 Views
Last Modified: 2008-03-04
Hello everyone,

Can somebody help me in telling me how to convert a LPTSTR to LPCTSTR. I do not want cstyle conversion but please suggest a function

Thanks
Gayatri
0
Comment
Question by:gisuresh
3 Comments
 
LVL 3

Accepted Solution

by:
stefanr earned 100 total points
ID: 2289763
If I understand your question correctly this is simple:

LPTSTR lpszModifyable = . . .
LPCTSTR lpszConstant = lpszModifyable;

No need to cast.
0
 
LVL 2

Expert Comment

by:tdubroff
ID: 2290649
What is suggested by stefanr actually performs an implicit cast from LPTSTR to LPCTSTR.  Identically you could use an explicit cast, but you say in your question that you don't want a c-style conversion.  I'm kind of confused by that remark, but here is a function which is what you asked for:

LPCTSTR convert(LPTSTR str)
{
    return (LPCTSTR(str));
}
0
 
LVL 6

Expert Comment

by:WxW
ID: 2291215
what for u need to convert LPCTSTR to LPTSTR . The space occupied is the same , C is only mean "const" , but thats a compiler thing , the program is not really interested .
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question