C++ Builder 參考手冊 ? System::Sysutils ? FloatToTextFmt
字符串轉為字符串,按照參數給定的格式
頭文件:#include <System.SysUtils.hpp>
命名空間:System::Sysutils
函數原型:
int __fastcall FloatToTextFmt(
char * Buf,
const void *Value,
TFloatValue ValueType,
char * Format);
int __fastcall FloatToTextFmt(
char * Buf,
const void *Value,
TFloatValue ValueType,
char * Format,
const TFormatSettings &AFormatSettings);
int __fastcall FloatToTextFmt(
System::WideChar * Buf,
const void *Value,
TFloatValue ValueType,
System::WideChar * Format);
int __fastcall FloatToTextFmt(
System::WideChar * Buf,
const void *Value,
TFloatValue ValueType,
System::WideChar * Format,
const TFormatSettings &AFormatSettings);
參數:
- Buf:用于返回生成的字符串;
- Value:需要分解的浮點數,System::Currency 或者 System::Extended 類型的變量地址;
- ValueType:指定參數 Value 的類型:
? fvExtended:參數 Value 是 System::Extended 類型的;
? fvCurrency:參數 Value 是 System::Currency 類型的; - Format:浮點數格式:請參考 FormatFloat 的格式說明;
- AFormatSettings:地區(qū)格式;請參考 請參考 FloatToStrF 的地區(qū)格式說明;
返回值:
- 函數返回生成的字符串的長度,生成的字符串通過參數 BufferArg 返回,
? 文檔并沒有說明 BufferArg 具體需要的字節(jié)數,在調用函數之前必須已經分配足夠的內存,可以根據參數估計或分配多一點內存 (比如 100 個字符長度);
? 通過參數 BufferArg 返回的字符串沒有結束符,根據源碼的使用情況分析,這個函數用于連續(xù)輸出字符到緩存,這樣做可以提高效率,不要忘記在使用生成的字符串之前要在字符串長度位置加一個結束符; - char * 類型的 BufferArg 參數的函數為過時的 ANSI 版本的函數,直接使用時可能有警告或報錯,已經移動到 System.AnsiStrings.hpp 頭文件里面了;
- 沒有 AFormatSettings 參數的函數不是線程安全的,因為使用了全局變量作為地區(qū)格式;帶有 AFormatSettings 參數的函數是線程安全的。
相關:
- System::Sysutils::FloatToStr
- System::Sysutils::FloatToStrF
- System::Sysutils::FloatToText
- System::Sysutils::FloatToTextFmt
- System::Sysutils::FloatToDecimal
- System::Sysutils::FloatToCurr
- System::Sysutils::TryFloatToCurr
- System::Sysutils::TextToFloat
- System::Sysutils::StrToFloat
- System::Sysutils::StrToFloatDef
- System::Sysutils::TryStrToFloat
- System::Sysutils::StrToCurr
- System::Sysutils::StrToCurrDef
- System::Sysutils::TryStrToCurr
- System::Sysutils::CurrToStr
- System::Sysutils::CurrToStrF
- System::Sysutils::FormatFloat
- System::Sysutils::FormatCurr
- System::Sysutils::TFloatRec
- System::Sysutils::TFloatValue
- System::Sysutils::FormatSettings
- System::Sysutils::TFormatSettings
- System::Sysutils::StrToBool
- System::Sysutils::StrToBoolDef
- System::Sysutils::TryStrToBool
- System::Sysutils::BoolToStr
- System::Sysutils::DateTimeToStr
- System::Sysutils::DateTimeToString
- System::Sysutils::DateToStr
- System::Sysutils::GUIDToString
- System::Sysutils::IntToStr
- System::Sysutils::IntToHex
- System::Sysutils::TimeToStr
- System::Sysutils::UIntToStr
- System::Sysutils
- System::Currency
- System
- std::itoa, std::_itoa, std::_itot, std::_itow
- std::ltoa, std::_ltoa, std::_ltot, std::_ltow
- std::ultoa, std::_ultoa, std::_ultot, std::_ultow
- std::_i64toa, std::_i64tot, std::_i64tow
- std::_ui64toa, std::_ui64tot, std::_ui64tow
- std::ecvt, std::_ecvt
- std::fcvt, std::_fcvt
- std::gcvt, std::_gcvt
- <cstdlib>
C++ Builder 參考手冊 ? System::Sysutils ? FloatToTextFmt