...
lib_str.h/lib_str.c
Prototype
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
CPU_CHAR *Str_FmtNbr_32 (CPU_FP32 nbr,
CPU_INT08U nbr_dig,
CPU_INT08U nbr_dp,
CPU_CHAR lead_char,
CPU_BOOLEAN nul,
CPU_CHAR *pstr);
|
Arguments
nbr
Number to format into a string.
...
Available only if LIB_STR_CFG_FP_EN
is DEF_ENABLED
in lib_cfg.h
(see section 5-1).
Notes / Warnings
For any unsuccessful string format or errors, an invalid string of question marks ('?'
) will be formatted, where the number of question marks is determined by the number of digits (nbr_dig
) and number of decimal point digits (nbr_dp
) to format. Also, whenever an invalid string is formatted for any reason, a NULL
pointer is returned.
...
Character array size must be >= (nbr_dig +
characters
nbr_dp +
1 negative sign +
1 decimal point +
1 NUL terminator)
Example Usage
Code Block | ||
---|---|---|
Language | C++ | CaptionText | CAPTION
| ||
CPU_CHAR AppBuf[20]; CPU_CHAR *pstr; pstr = Str_FmtNbr_32((CPU_FP32 )-1234.5678, (CPU_INT08U ) 5, (CPU_INT08U ) 2, (CPU_CHAR ) ' ', (CPU_BOOLEAN) DEF_NO, (CPU_BOOLEAN) DEF_YES, (CPU_CHAR *)&AppBuf[0]); |