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?
Wrong indexing, try (*zm)[1]
instead. And check for errors from library calls.
尝试*(zm + 1)分配第二个元素的值*(zm + 1)= 10;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.