One of the problems I see is this
return *output;
It is actually returning output[0] here when you want it to return the address of output array.
It should just be
return output;
Sorry fellows Daniweb is loading too slow on my side so when I was posting I couldn't see your replies... ;)