Hi,
The following function is supposed to return a const char from a float. But instead the warning I get says it is returning the address of the local variable ans
How to achieve the return of a const char and not the address of ans?Code:#include <cstdio> char *ftostr(float dVar) { char ans[20]; snprintf(ans, 20, "%f", dVar); return ans; }




Reply With Quote