My C program is crashing and I am too new to figure it out. It\'s very simple so far and I imagine the code is enough to figure out what is going wrong.
I am simply try
realloc()
may return a different pointer than the original one but you assign that to temp
only so the calling function still works with the original pointer afterwards. Change double_array_size()
to return the new pointer returned by realloc()
and call
d = double_array_size(d, array_size);
Furthermore you should always check the result fo malloc()
, realloc()
etc. They may return NULL if there is no more memory available