In reply to yasirdv:
The basic problem is the output of fp_func is a string, and you are trying to display that result with a %h format which requires an integral type. That is illegal and should be an error. The string data type does not allow the character ‘\0’ and will remove ir.
Also as cgales mentions, you only allocated 4 bytes to out_cipher, yet you are tring to write to the 5th byte. You are just lucky this did corrupt anything else.
It is not clear why you are trying to have your function return a string and not a unsigned int. If you could explain that, maybe we can suggest a better solution.