stof
將字元序列轉換成浮點數。
float stof(
const string& _Str,
size_t *_Idx = 0
);
float stof(
const wstring& _Str,
size_t *_Idx = 0
);
參數
參數 |
描述 |
---|---|
_Str |
要轉換的字元序列。 |
_Idx |
第一個未轉換字元的索引值。 |
傳回值
浮點值。
備註
函式轉換項目的序列。 _Str 的成員型別 float 的值 _Val ,就像是藉由呼叫 strtof(_Str.c_str(), _Eptr), _Eptr 是內部物件的物件傳遞給函式。 如果 _Str.c_str() == *_Eptr 就會擲回型別 invalid_argument物件。 如果這類的呼叫會將 errno,就會擲回型別 out_of_range物件。 則為,否則為,表示 _Idx 不為 null 指標, *_Idx 函式的存放區 *_Eptr - _Str.c_str() 並傳回 _Val。
需求
標題: <string>
命名空間: std