This is a homework assignment so I don’t want to post any code, but I’m pretty stumped with the bug that I have.
Currently I have a array that has been malloced and am copying the pointer to the array. Now, I can memcpy and memmove with this array and that works fine.
However, when I do a realloc with it an invalid pointer error comes up – and I have absolutely no idea why.
Can anyone help?
you said ‘I copy the pointer to this array into another variable’. The problem is as soon as you do a realloc, the original pointer is no longer valid. I dont see the reason to copy the pointer to a variable?