Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with array of pointers

Status
Not open for further replies.

mattcs

Technical User
Jul 21, 2002
32
AU
The code below compiles OK but CodeGuard brings up a "Resource type mismatch: a(n) object was expected." error when I run it. Stepping through, the error occurs when trying to 'delete'. Can anyone give me a clue as to what I am doing wrong (something pretty basic no doubt).
--------------------
char *buffer[3];
for(int index = 0; index < 3; index++)
buffer[index] = new char[50];

// do stuff here

for(int index = 0; index < 3; index++)
delete buffer[index];
delete [] buffer;
--------------------
Thanks
 
I've figured the answer for those interested. The following is the amended code for the 'delete' part (the most obvious things stare you in the face but you still can't see them).

for(int index = 0; index < 3; index++)
delete [] buffer[index];

That's all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top