never9
June 3rd, 1999, 08:30 PM
#include <iostream.h>
void main()
{
char **pp = new char*[10];
char *p[10];
for(int i=0; i<10; i++)
p[i] = new char[10];
p[0] = "This";
p[1] = " is";
p[2] = " a";
p[3] = " test";
p[4] = " version.";
p[5] = " You";
p[6] = "know?";
p[7] = " I";
p[8] = " love";
p[9] = " you..";
for(i=0; i<10; i++)
{
pp[i] = p[i];
cout << pp[i] << endl;
}
for(i=0; i<10; i++)
delete [] pp[i]; // <== Here is the problem
delete [] pp;
}
This is my test version of double pointer.
Almost everything is executed well.
But the execution is halted in the arrow marked
position.
Could you give me a solution to this problem.
I programmed this source in Visual C++ 6.0.
I can't understand the fact that
when I execute this source in Debug mode,
the execution is halted but in Release mode,
it's OK.
Need your help
void main()
{
char **pp = new char*[10];
char *p[10];
for(int i=0; i<10; i++)
p[i] = new char[10];
p[0] = "This";
p[1] = " is";
p[2] = " a";
p[3] = " test";
p[4] = " version.";
p[5] = " You";
p[6] = "know?";
p[7] = " I";
p[8] = " love";
p[9] = " you..";
for(i=0; i<10; i++)
{
pp[i] = p[i];
cout << pp[i] << endl;
}
for(i=0; i<10; i++)
delete [] pp[i]; // <== Here is the problem
delete [] pp;
}
This is my test version of double pointer.
Almost everything is executed well.
But the execution is halted in the arrow marked
position.
Could you give me a solution to this problem.
I programmed this source in Visual C++ 6.0.
I can't understand the fact that
when I execute this source in Debug mode,
the execution is halted but in Release mode,
it's OK.
Need your help