I'm trying to truncate with a certain LPCTSTR string to n position and
get another LPCTSTR variable truncated by that n position....
Is it possible? Any hint?...
Thanks
Ciao
Luigi
"Luigino" <npu...@rocketmail.com> wrote in message
news:6e2fc0ea-6206-4e9d...@j27g2000yqn.googlegroups.com...
--
Scott McPhillips [VC++ MVP]
> I'm trying to truncate with a certain LPCTSTR string to n position and
> get another LPCTSTR variable truncated by that n position....
In addition to Scott's correct post, you may want to use CString::Left
method:
http://msdn.microsoft.com/en-us/library/sw4as8az(VS.80).aspx
Giovanni
LPCTSTR str = _T("My Test String");
CString cstr(str);
cstr.Mid(0,5); // n =5 here,
LPCTSTR NewStr = cstr;
"Luigino" wrote:
> .
>
LPCTSTR str = _T("My Test String");
CString cstr(str);
LPCTSTR NewStr = cstr.Mid(0,5); // n =5 here
Is this a homework assignment?
-- David
CString s;
s = ...;
CString truncated_s(s.Left(n));
CString rest_of_s(s.Mid(n + 1));
In MFC, it RARELY makes sense to be using LPCTSTR for any data in your own program. It is
something to be used under rare and exotic circumstances. In the worst case, I might
write a couple LPTSTR declarations in a program, mostly to get writeable buffers for API
calls. But I would never consider LPCTSTR as a reasonable data structure for ordinary
work. Or LPTSTR, either.
If you are seriously using LPTSTR/LPCTSTR, you should reconsider how you are writing code.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm