11/04/2009

pointer pointer array - for memory

#define MAX_PATH 128

class TestPointer
{
private:
char strBuffer** m_pstrBuffer;
public:
void read_text_file( char* _strFileName );
};
void TestPointer::read_text_file( char* _strFileName )
{
int strNum;
//...........

m_pStrBuffer = (char**)new char[strNum];


m_pStrBuffer = (char*)new char[MAX_PATH];

char szbuf[128];
fprintf( fp, "%s", szbuf );
strcpy( m_pStrBuffer[index], szbuf );

}

void clear(void)
{
for( int i = 0; i < strNum; ++i )
delete m_pStrBuffer[index];

delete m_pStrBuffer;

}

댓글 없음: