+ 1
Can anyone help me with this task?
I need to create a new array in dynamic memory and the function must return a pointer to that array, but I don't understand how I can do it https://code.sololearn.com/cgJcS39K0ePh/?ref=app
2 Antworten
+ 2
There are number of problems
Line 17, you set an abject it to the pointer. The type is wrong and you try yo write over the pointer which point to the array you have allocated on line 15.
You should delete line 17
Before your two returns, lines 35 and 52, you need to free the memory you have allocated
Before 35: free(items);
Before 52: free(tmp_items);
Your move function doesn't work if k>=n, you should it after you get the value of k, line 41
+ 2
The function move need to return an integer, and also the function main