char* f(){
char* result;//I have to return 'result' at the end of this function, where result should be containing i (i.e. int i=97) in it.
int i = 97;
//Do whatever you can
return result;
}
<nolyc> You're trying to do X, and you thought of solution Y. So you're asking about solution Y, without even mentioning X. The problem is, there might be a better solution, but we can't know that unless you describe what X is.
That's not the ideal solution though, it is error prone and the user would have to look up documentation to see what kind of pointer is being outputted and whether they need to handle deallocation or not.