Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to delete a CstringArray?

996 views
Skip to first unread message

Richard Kirchknopf

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
myCstringarray.RemoveAt(i); ?????

"Lijun Yan" <kela...@263.net> wrote in message news:udnEuUSx$GA....@cppssbbsa02.microsoft.com...
> Hi,
>
> after I add some Cstring into CStringArray, I want to delete the
> CStringArray, How to do it?
>
> use "delete myCstringarray[i] " will occur a compile error.
>
> Thanks in advance
>
> Lijun Yan


Cabadam

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
delete is used to delete memory locations referenced by pointers... the [ ]
operator here doesn't return a pointer, it returns an actual CString object.
you should be able to just say myCStringArray.RemoveAll();
or just let myCStringArray go out of scope and it will probably all
disappear

--
Adam
pan...@comwerx.net
http://members.xoom.com/Q3KillStats
http://cabadam.freewebsites.com


"Lijun Yan" <kela...@263.net> wrote in message

news:uk5CvxSx$GA....@cppssbbsa02.microsoft.com...
> for(UINT i=0; i < myCStringArray.GetSize(); i++)
> delete myCStringArray[i]; // complie error
> myCStringArray.RemoveAll();
>
> question as above.
> thx
>
>
> "Richard Kirchknopf" <spamof...@interlog.com> wrote in message
> news:OqLIDtSx$GA.247@cppssbbsa05...

Lijun Yan

unread,
May 24, 2000, 3:00:00 AM5/24/00
to

Lijun Yan

unread,
May 24, 2000, 3:00:00 AM5/24/00
to
for(UINT i=0; i < myCStringArray.GetSize(); i++)
delete myCStringArray[i]; // complie error
myCStringArray.RemoveAll();

question as above.
thx


"Richard Kirchknopf" <spamof...@interlog.com> wrote in message
news:OqLIDtSx$GA.247@cppssbbsa05...
> myCstringarray.RemoveAt(i); ?????
>
> "Lijun Yan" <kela...@263.net> wrote in message
news:udnEuUSx$GA....@cppssbbsa02.microsoft.com...

Shraddha

unread,
May 24, 2000, 3:00:00 AM5/24/00
to
use myCStringArray.RemoveAll()

Marc LOIRY

unread,
May 24, 2000, 3:00:00 AM5/24/00
to
UINT cb= myCStringArray.GetSize();
for(UINT i=cb-1; i>=0; i--)
delete myCStringArray[i];
myCStringArray.RemoveAll();

don't try to delete an item already deleted !
it's better !!!!

Marc

Tenebrax

unread,
May 24, 2000, 3:00:00 AM5/24/00
to

"Lijun Yan" <kela...@263.net> a écrit dans le message news:

udnEuUSx$GA....@cppssbbsa02.microsoft.com...
> Hi,
>
> after I add some Cstring into CStringArray, I want to delete the
> CStringArray, How to do it?
>
> use "delete myCstringarray[i] " will occur a compile error.
>
> Thanks in advance

Stoled from MSDN (CStringArray):

"When a CString array is deleted, or when its elements are removed, string
memory is freed as appropriate."

So all you have to do is calling RemoveAt(...) or RemoveAll()...


--
Tenebrax
http://graff.ctw.net

Igor Sukhov

unread,
May 24, 2000, 3:00:00 AM5/24/00
to
HI !

for(UINT i=0; i < myCStringArray.GetSize(); i++)

myCStringArrayÀ.RemoveAt(i);

Hope it'll help, and take a look at MSDN !

--
Best regards,

-----------
Igor Sukhov (Brainbench/Tekmetrics ID:50759)
igor_...@mail.ru | s...@ipian.kazan.ru | ICQ:57404554 | http://siv.da.ru

Hi, Lijun Yan <kela...@263.net>! You wrote:
> for(UINT i=0; i < myCStringArray.GetSize(); i++)
> delete myCStringArray[i]; // complie error
> myCStringArray.RemoveAll();
>
> question as above.
> thx
>
>
> "Richard Kirchknopf" <spamof...@interlog.com> wrote in message
> news:OqLIDtSx$GA.247@cppssbbsa05...
> > myCstringarray.RemoveAt(i); ?????
> >

> > "Lijun Yan" <kela...@263.net> wrote in message


> news:udnEuUSx$GA....@cppssbbsa02.microsoft.com...
> > > Hi,
> > >
> > > after I add some Cstring into CStringArray, I want to delete the
> > > CStringArray, How to do it?
> > >
> > > use "delete myCstringarray[i] " will occur a compile error.
> > >
> > > Thanks in advance
> > >

> > > Lijun Yan
> >
> >
> >
>
>

0 new messages