Invalid pointer aborted core dumped

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    row=20, col=20;
    Organism** organisms= new Organism* [row];
    for(int i=0; i<row; i++)
    {
        organisms[i]=new Organism[col];

    }

.....Some long codes

    for(int i=0;i<row;i++){
            delete [] organisms [i];
            }
    delete[] organisms;


//gives me invalid pointer core dumped 
Last edited on
Are you sure this is the particular line which is giving you the problem?
I'd suggest making some cout statements and seeing what variables are being passed.
Or comment out functions line by line until you get the core dumped error;
then you know where something fucky is happening.
I added this and I do not get error, but is the logic ok?

for(int i=0;i<row;i++){
if(organism[i]==NULL)
delete [] organisms [i];
}
delete[] organisms;

I also did GDB and it says, cannot access memory at 0X......

Invalid syntax delete[]

Can you please tell me what is the max objects I can assign to organisms every index?
Last edited on
Topic archived. No new replies allowed.