¿ªÔÆÌåÓý

Re: Help!


 

Hi Dr. Fred.

Arv mentions one specific way to convert.

Another, more general way (at the expense of [I expect] more memory) is
to use snprintf(destinationBuffer, bufferSize, formatString, data...);
This is very similar to the normal "printf()" statement except it sends
the "output" to a character buffer rather than the standard output device.

"destinationBuffer" is a character string to hold the formatted data,
"bufferSize" is the size of the destination buffer (using sizeof() is very
useful for this variable), formatString is the normal "printf" style format
string, and "data..." is the data to format and place in the buffer.

This allows you to format integers, floating point, string, and just about
any thing else. Very useful, unless you get really memory constrained.
(Then there are other techniques which may be used.)

BTW, you will also see "sprintf()" used, but it has the "problem" that is
is all too easy to overwrite the destination buffer resulting in general
corruption. Something which may be extremely difficult to diagnose.

I hope this helps.

73

- Mark N1VQW

Join [email protected] to automatically receive all group messages.