You have to remember that arrays decays to pointers, so in the loadName
function the variable N
is actually a pointer, and behaves like any other local variable. That means that if you reassign it you only reassign the local copy of the pointer. That's the first thing.
The second thing is that you pass in a pointer to already allocated memory, an array that hold five structures. No need to allocate again inside the function.
Which leads me to the third thing, that you allocate in every iteration of the loop, thereby loosing the previous allocation and leaking memory.
You should take care though, as the array you pass only have allocated space for five structures, if you try to read any more than that you will write beyond the limits of the array and will have a buffer overflow which leads to so called undefined behavior.