|
The way fcvt works is that it returns a pointer to a static variable inside its function, much like strtok. Therefore, the memory is already allocated and all you have to do is point to it. Thus, you use a char *. Also note that calling fcvt again will overwrite whatever was returned previously. Therefore, you should immediately do a strcpy(localString, stringFromFcvt) so that you don't loose the data.
itoa, on the other hand, probably does the strcpy for you, meaning that the buffer needs to already be allocated and large enough to accept the string.
Other random fcvt notes: Remember that fcvt will not insert a decimal point in the string for you. The location of this decimal point is returned as the third parameter to the function. Same with the sign, which is returned as the fourth.
|