Alternative to void * pointer in my project

You cannot return your command like this. The pointer points to a place in memory that is local to this function.

When the function is left, this memory is not available anymore.

You should reserve this space before calling the function and then hand that to the function...