From: Luigino on
Hello everyone,

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
From: Scott McPhillips [MVP] on
The 'C' in LPCTSTR stands for 'const', so you can't change that string.
Copy the n chars that you want into a new string.


"Luigino" <npuleio(a)rocketmail.com> wrote in message
news:6e2fc0ea-6206-4e9d-a7ab-b21cf758ce8e(a)j27g2000yqn.googlegroups.com...
> Hello everyone,
>
> 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

--
Scott McPhillips [VC++ MVP]

From: Giovanni Dicanio on
"Luigino" <npuleio(a)rocketmail.com> ha scritto nel messaggio
news:a6584f98-f862-4fb9-a9fd-f2f9542dbd3f(a)b7g2000yqd.googlegroups.com...

> 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


From: nexolite on
you can do this in the following way:

LPCTSTR str = _T("My Test String");
CString cstr(str);
cstr.Mid(0,5); // n =5 here,
LPCTSTR NewStr = cstr;


"Luigino" wrote:

> Hello everyone,
>
> 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
> .
>
From: nexolite on
oh sorry made a typing mistake in the above reply it should be:

LPCTSTR str = _T("My Test String");
CString cstr(str);
LPCTSTR NewStr = cstr.Mid(0,5); // n =5 here




"nexolite" wrote:

> you can do this in the following way:
>
> LPCTSTR str = _T("My Test String");
> CString cstr(str);
> cstr.Mid(0,5); // n =5 here,
> LPCTSTR NewStr = cstr;
>
>
> "Luigino" wrote:
>
> > Hello everyone,
> >
> > 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
> > .
> >
 |  Next  |  Last
Pages: 1 2
Prev: OnClose() in CPropertySheet
Next: Truncate a LPCTSTR