Reputation: 2999
Probably my brain is not working properly now... I wonder why I receive mentioned error in my code:
int ** zm;
zm = (int**)calloc(1, sizeof(int*));
*zm = (int*)calloc(1, sizeof(int));
*zm[0] = 5;
*zm = (int*)realloc(*zm, 2*sizeof(int));
*zm[1] = 10; // Access violation reading location 0xFFFFFFFFFFFFFFFF
Could someone explain what happend in that code?
Upvotes: 3
Views: 1290
Reputation: 84189
Wrong indexing, try (*zm)[1]
instead. And check for errors from library calls.
Upvotes: 5