Tag dynamic-memory-allocation

[Solved] Why the address of structure and next is not same?

TL;DR Your code provokes Undefined Behavior, as already mentioned in Morlacke’s Answer. Other than that, it seems that you’re having problems on understanding how pointers work. See references for tutorials. First, From your comments When you say that there’s memory…

[Solved] C memory allocationd [closed]

I want to have a array of struct A, so I declared the array in function ‘mem_init’. this is not what you did because struct A *arr_A[n]; is an array of pointers tostruct A. An array of struct A can…

[Solved] Using realloc() on a Stack

From the man page: The realloc() function changes the size of the memory block pointed to by ptr to size bytes. So instead of: int *newbuffer = (int*) realloc (stacky, size); you probably want int *newbuffer = (int*) realloc (stacky,…