Hello, so here below is a void function that transposes a dynamic array.
It works for some inputs that I try but for other inputs I insert I get this warning:
TRANS(41432,0x7fff74a20000) malloc: *** error for object 0xa000000000000000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
It seems like there is some memory leak but I´m new in c++ programming and can´t figure out what it is that I need to fix. Do you have any tips ?
You need to delete the memory in the reverse order from what you allocated the memory. In this case you need to use a loop to delete tmp[] then you must delete[] *arr.