Click here to Skip to main content
15,918,211 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Changing Documents in SDI app Pin
Ben Burnett24-Aug-01 15:55
Ben Burnett24-Aug-01 15:55 
GeneralFind controls on Window Pin
24-Aug-01 5:02
suss24-Aug-01 5:02 
GeneralRe: Find controls on Window Pin
Matt Gullett24-Aug-01 5:06
Matt Gullett24-Aug-01 5:06 
GeneralRe: Find controls on Window Pin
24-Aug-01 5:52
suss24-Aug-01 5:52 
GeneralRe: Find controls on Window Pin
Matt Gullett24-Aug-01 6:05
Matt Gullett24-Aug-01 6:05 
GeneralRe: Find controls on Window Pin
24-Aug-01 6:07
suss24-Aug-01 6:07 
GeneralRe: Find controls on Window Pin
24-Aug-01 6:17
suss24-Aug-01 6:17 
GeneralDeleting a dynamically allocated 2d array Pin
Josh Knox24-Aug-01 4:11
Josh Knox24-Aug-01 4:11 
Hey everyone,
I'm having a problem deleting a dynamically allocated array of strings.

I do something like this to allocate the array of strings:
.
.
.
char** arrayofstrings = new char*[stringcount];    //allocate an array of string pointers

for(int i = 0; i < stringcount; i++)               
{
     arrayofstrings[i] = new char[MAX_STRING];     //set each pointer in the array to an array of chars
}
.
.
.

I do something like this to delete the array of strings:
.
.
.
for(i = 0; i < stringcount; i++)
{
     delete [] arrayofstrings[i];                //delete each string in the array
     arrayofstrings[i] = NULL;
}

delete [] arrayofstrings;                        //delete the array of string pointers
arrayofstrings = NULL;

The deletion code always crashes. I've done this before with no problem, but its early and I've got a splitting hangover(damn Thirsty Thursday) and can't seem to make sense of it.

Can anyone point me in the right direction?

Oh yeah, what's the tag to format my code in the forums?

Thanks for any help....

Josh
josh@that-guy.net
GeneralRe: Deleting a dynamically allocated 2d array Pin
Tim Deveaux24-Aug-01 6:00
Tim Deveaux24-Aug-01 6:00 
GeneralRe: Deleting a dynamically allocated 2d array (part II) Pin
Tim Deveaux24-Aug-01 8:39
Tim Deveaux24-Aug-01 8:39 
GeneralBorland C++ Builder : DLL Load Error Pin
AaroC35724-Aug-01 4:04
AaroC35724-Aug-01 4:04 
QuestionHow to remove the maximize button... Pin
Maer72724-Aug-01 3:28
Maer72724-Aug-01 3:28 
AnswerRe: How to remove the maximize button... Pin
Zoltan Csizmadia24-Aug-01 4:14
Zoltan Csizmadia24-Aug-01 4:14 
GeneralRe: How to remove the maximize button... Pin
Maer72724-Aug-01 22:21
Maer72724-Aug-01 22:21 
QuestionHow can I get the KB articles? Pin
Maer72724-Aug-01 3:27
Maer72724-Aug-01 3:27 
AnswerRe: How can I get the KB articles? Pin
Josh Knox24-Aug-01 4:16
Josh Knox24-Aug-01 4:16 
GeneralRe: How can I get the KB articles? Pin
Maer72724-Aug-01 22:33
Maer72724-Aug-01 22:33 
GeneralBitmap dialog drawing problem Pin
24-Aug-01 3:14
suss24-Aug-01 3:14 
GeneralBitmap dialog drawing problem Pin
24-Aug-01 3:13
suss24-Aug-01 3:13 
GeneralVisual Studio and stray files Pin
John Hagen24-Aug-01 2:39
John Hagen24-Aug-01 2:39 
QuestionHow change network drive name? Pin
24-Aug-01 1:09
suss24-Aug-01 1:09 
GeneralDirectX and timers Pin
24-Aug-01 0:52
suss24-Aug-01 0:52 
GeneralRe: DirectX and timers Pin
Anders Molin24-Aug-01 1:16
professionalAnders Molin24-Aug-01 1:16 
GeneralRe: DirectX and timers Pin
Andrew Peace24-Aug-01 13:21
Andrew Peace24-Aug-01 13:21 
GeneralRe: DirectX and timers Pin
25-Aug-01 3:36
suss25-Aug-01 3:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.