[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Newbie question: The correct way to delete a pointer array to a pointer
From: |
Thomas |
Subject: |
Newbie question: The correct way to delete a pointer array to a pointer array |
Date: |
Fri, 25 Feb 2005 12:45:54 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050104 Fedora/1.7.5-2.1.2.kde |
I'm using the following
char** m_pcPuzzle;
to create an array for to store a crossword puzzle. I allocate memory
using the next few lines
//allocate memory for new map
m_pcPuzzle=new char*[m_iWidth];
for (int x=0;x<rhs.m_iWidth;x++)
m_pcPuzzle[x]=new char[m_iHeight];
What is the correct way for me to call delete?
Should I just do
for (int x=0;x<m_iWidth;x++)
delete m_pcPuzzle[x];
delete [] m_pcPuzzle;
Am I allocating the memory correctly?
Thanks,
Thomas
- Newbie question: The correct way to delete a pointer array to a pointer array,
Thomas <=