C++ Builder 參考手冊(cè) ? System::Sysutils ? StrToUInt
字符串轉(zhuǎn)無(wú)符號(hào)整數(shù)值
頭文件:#include <System.SysUtils.hpp>
命名空間:System::Sysutils
函數(shù)原型:
unsigned __fastcall StrToUInt(const System::UnicodeString S);
參數(shù):
- S:字符串摆舟;
返回值:
- 無(wú)符號(hào)整數(shù)類型數(shù)值,如果轉(zhuǎn)換失敗瘤载,拋出 EConvertError 異常;
- 字符串可以是十進(jìn)制或十六進(jìn)制數(shù)據(jù):以 "0x" 開(kāi)頭認(rèn)為是十六進(jìn)制數(shù)據(jù),否則認(rèn)為是十進(jìn)制滋恬,不支持八進(jìn)制及其他進(jìn)制幼苛;
- 函數(shù) StrToUInt超全、StrToUIntDef 和 TryStrToUInt 的區(qū)別:
? StrToUInt 轉(zhuǎn)換失敗拋出異常把将;
? StrToUIntDef 轉(zhuǎn)換失敗返回默認(rèn)值轻专;
? TryStrToUInt 轉(zhuǎn)換結(jié)果通過(guò)參數(shù)返回,函數(shù)返回值返回是否轉(zhuǎn)換成功察蹲。
例:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Memo1->Lines->Add(StrToUInt(L"123"));
Memo1->Lines->Add(StrToUInt(L"0123"));
Memo1->Lines->Add(StrToUInt(L"0x123"));
Memo1->Lines->Add(StrToUInt(L"0xABCDE"));
Memo1->Lines->Add(StrToUInt(L"0xFFFFFFFF"));
}
運(yùn)行結(jié)果:
相關(guān):
- System::Sysutils::IntToStr
- System::Sysutils::IntToHex
- System::Sysutils::UIntToStr
- System::Sysutils::Format
- System::Sysutils::FormatBuf
- System::Sysutils::StrToBool
- System::Sysutils::StrToBoolDef
- System::Sysutils::StrToCurr
- System::Sysutils::StrToCurrDef
- System::Sysutils::StrToDate
- System::Sysutils::StrToDateDef
- System::Sysutils::StrToDateTime
- System::Sysutils::StrToDateTimeDef
- System::Sysutils::StrToFloat
- System::Sysutils::StrToFloatDef
- System::Sysutils::StrToInt
- System::Sysutils::StrToIntDef
- System::Sysutils::StrToInt64
- System::Sysutils::StrToInt64Def
- System::Sysutils::StrToTime
- System::Sysutils::StrToTimeDef
- System::Sysutils::StrToUInt
- System::Sysutils::StrToUIntDef
- System::Sysutils::StrToUInt64
- System::Sysutils::StrToUInt64Def
- System::Sysutils::TimeToStr
- System::Sysutils::TryStrToBool
- System::Sysutils::TryStrToCurr
- System::Sysutils::TryStrToDate
- System::Sysutils::TryStrToDateTime
- System::Sysutils::TryStrToFloat
- System::Sysutils::TryStrToInt
- System::Sysutils::TryStrToInt64
- System::Sysutils::TryStrToTime
- System::Sysutils::TryStrToUInt
- System::Sysutils::TryStrToUInt64
- System::Sysutils
- std::atof, std::_ttof, std::_wtof
- std::_atold, std::_ttold, std::_wtold
- std::atoi, std::_ttoi, std::_wtoi
- std::atol, std::_ttol, std::_wtol
- std::atoll, std::_ttoll, std::_wtoll
- std::_atoi64, std::_ttoi64, std::_wtoi64
- std::strtof, std::_tcstof, std::wcstof
- std::strtod, std::_tcstod, std::wcstod
- std::strtold, std::wcstold, std::_strtold, std::_tcstold, std::_wcstold
- std::strtol, std::_tcstol, std::wcstol
- std::strtoll, std::_tcstoll, std::wcstoll
- std::strtoul, std::_tcstoul, std::wcstoul
- std::strtoull, std::_tcstoull, std::wcstoull
- <cstdlib>
C++ Builder 參考手冊(cè) ? System::Sysutils ? StrToUInt