Link to home
Start Free TrialLog in
Avatar of Surfer
Surfer

asked on

CStringArray and CString deallocation??

How do I deallocate the memory for the following code?

CStringArray ob ;      
CString s ;
CString *pStr ;
ob.SetSize( 0,100 );
for (INT ni=0;ni< 3/*1000*/;++ni) {
pStr = new CString ;
pStr->Format("Test String %d",ni) ;
ob.Add ( pStr->GetBuffer(0) );
pStr->ReleaseBuffer(-1 ) ;
}

CString s1 ;
s1 = ob.GetAt(1) ;

I tried:
for (INT n=0;n<3;++n)
delete (CString*) ob.GetAt(n) ;
and
delete ob.GetAt(n) ;
but the compiler complains.  
Avatar of Surfer
Surfer

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial