C++ åèæå
- C++11
- C++14
- C++17
- C++20
- C++ ç¼è¯å¨æ¯ææ åµè¡¨
- ç¬ç«ä¸å®¿ä¸»å®ç°
- C++ è¯è¨
- C++ å ³é®è¯
- é¢å¤çå¨
- C++ æ ååºå¤´æä»¶
- å ·åè¦æ±
- åè½ç¹æ§æµè¯ (C++20)
- å·¥å ·åº
- ç±»åæ¯æï¼åºæ¬ç±»åãRTTIãç±»åç¹æ§ï¼
- æ¦å¿µåº (C++20)
- é误å¤ç
- 卿å å管ç
- æ¥æåæ¶é´å·¥å ·
- å符串åº
- std::basic_string
- std::basic_string<CharT,Traits,Allocator>::npos
- std::basic_string<CharT,Traits,Allocator>::at
- std::hash (std::string, std::wstring, std::u16string, std::u32string, std::pmr::string, std::pmr::wstring, std::pmr::u16string, std::pmr::u32string)
- std::basic_string<CharT,Traits,Allocator>::assign
- std::basic_string<CharT,Traits,Allocator>::get_allocator
- std::basic_string<CharT,Traits,Allocator>::substr
- std::basic_string<CharT,Traits,Allocator>::basic_string
- std::basic_string<CharT,Traits,Allocator>::operator=
- std::basic_string<CharT,Traits,Allocator>::operator[]
- std::basic_string<CharT,Traits,Allocator>::front
- std::basic_string<CharT,Traits,Allocator>::back
- std::basic_string<CharT,Traits,Allocator>::data
- std::basic_string<CharT,Traits,Allocator>::c_str
- std::basic_string<CharT,Traits,Allocator>::operator basic_string_view
- std::basic_string<CharT,Traits,Allocator>::begin, std::basic_string<CharT,Traits,Allocator>::cbegin
- std::basic_string<CharT,Traits,Allocator>::end, std::basic_string<CharT,Traits,Allocator>::cend
- std::basic_string<CharT,Traits,Allocator>::rbegin, std::basic_string<CharT,Traits,Allocator>::crbegin
- std::basic_string<CharT,Traits,Allocator>::rend, std::basic_string<CharT,Traits,Allocator>::crend
- std::basic_string<CharT,Traits,Allocator>::empty
- std::basic_string<CharT,Traits,Allocator>::size, std::basic_string<CharT,Traits,Allocator>::length
- std::basic_string<CharT,Traits,Allocator>::max_size
- std::basic_string<CharT,Traits,Allocator>::reserve
- std::basic_string<CharT,Traits,Allocator>::capacity
- std::basic_string<CharT,Traits,Allocator>::shrink_to_fit
- std::basic_string<CharT,Traits,Allocator>::clear
- std::basic_string<CharT,Traits,Allocator>::insert
- std::basic_string<CharT,Traits,Allocator>::erase
- std::basic_string<CharT,Traits,Allocator>::push_back
- std::basic_string<CharT,Traits,Allocator>::pop_back
- std::basic_string<CharT,Traits,Allocator>::append
- std::basic_string<CharT,Traits,Allocator>::operator+=
- std::basic_string<CharT,Traits,Allocator>::compare
- std::basic_string<CharT,Traits,Allocator>::starts_with
- std::basic_string<CharT,Traits,Allocator>::ends_with
- std::basic_string<CharT,Traits,Allocator>::replace
- std::basic_string<CharT,Traits,Allocator>::copy
- std::basic_string<CharT,Traits,Allocator>::resize
- std::basic_string<CharT,Traits,Allocator>::swap
- std::basic_string<CharT,Traits,Allocator>::find
- std::basic_string<CharT,Traits,Allocator>::rfind
- std::basic_string<CharT,Traits,Allocator>::find_first_of
- std::basic_string<CharT,Traits,Allocator>::find_first_not_of
- std::basic_string<CharT,Traits,Allocator>::find_last_of
- std::basic_string<CharT,Traits,Allocator>::find_last_not_of
- std::operator+(std::basic_string)
- std::swap(std::basic_string)
- std::literals::string_literals::operator""s
- std::erase, std::erase_if (std::basic_string)
- operator<<,>>(std::basic_string)
- std::getline
- operator==,!=,<,<=,>,>=,<=>(std::basic_string)
- std::stoi, std::stol, std::stoll
- std::stoul, std::stoull
- std::stof, std::stod, std::stold
- std::to_string
- std::to_wstring
- std::basic_string çæ¨å¯¼æå¼
- std::basic_string_view
- ç©ºç»æ¢åèå符串
- ç©ºç»æ¢å¤åèå符串
- ç©ºç»æ¢å®½å符串
- std::char_traits
- 注é
- 容å¨åº
- è¿ä»£å¨åº
- èå´åº (C++20)
- ç®æ³åº
- æ°å¼åº
- è¾å ¥/è¾åºåº
- æä»¶ç³»ç»åº
- æ¬å°ååº
- æ£å表达å¼åº
- ååæä½åº
- çº¿ç¨æ¯æåº
- å®éªæ§ C++ ç¹æ§
- æç¨çèµæº
- ç´¢å¼
- std 符å·ç´¢å¼
- åç¨æ¯æ (C++20)
- C++ å ³é®è¯
ä½ç½®ï¼é¦é¡µ > C++ åèæå >åç¬¦ä¸²åº >std::basic_string > std::stoul, std::stoull
std::stoul, std::stoull
| å®ä¹äºå¤´æä»¶ <string>
|
||
| unsigned long    stoul( const std::string& str, std::size_t* pos = 0, int base = 10 ); unsigned long    stoul( const std::wstring& str, std::size_t* pos = 0, int base = 10 ); |
(1) | (C++11 èµ·) |
| unsigned long long stoull( const std::string& str, std::size_t* pos = 0, int base = 10 ); unsigned long long stoull( const std::wstring& str, std::size_t* pos = 0, int base = 10 ); |
(2) | (C++11 èµ·) |
转è¯å符串 str ä¸çæ ç¬¦å·æ´æ°å¼ã
è弿æç©ºç½ç¬¦ï¼ä»¥è°ç¨ isspace() é´å«ï¼ï¼ç´å°æ¾å°é¦ä¸ªé空ç½ç¬¦ï¼ç¶ååå°½å¯è½å¤çåç¬¦ç»æåº n ï¼å
¶ä¸ n=base ï¼çæ ç¬¦å·æ´æ°è¡¨ç¤ºï¼å¹¶å°å®ä»¬è½¬æ¢æä¸ä¸ªæ´æ°å¼ãåæ³çæ ç¬¦å·æ´æ°å¼ç±ä¸åé¨åç»æï¼
- (å¯é)æ£æè´å·
- (å¯é)æç¤ºå
«è¿å¶åºçåç¼ï¼
0ï¼ï¼ä» å½åºä¸º 8 æ â0â æ¶åºç¨ï¼ - (å¯é)æç¤ºåå
è¿å¶åºçåç¼ï¼
0xæ0Xï¼ï¼ä» å½åºä¸º 16 æ â0â æ¶åºç¨ï¼ - ä¸ä¸ªæ°ååºå
åºç忳鿝 {0,2,3,...,36} ãåæ³æ°åé对äºåº 2 æ´æ°æ¯ {0,1}ï¼å¯¹äºåº3æ´æ°æ¯ {0,1,2} ï¼ä»¥æ¤ç±»æ¨ã对äºå¤§äº 10 çåºï¼åæ³æ°åå
å«åæ¯å符ï¼ä»å¯¹äºåº 11 æ´æ°ç Aa å°å¯¹äºåº36æ´æ°ç Zz ã忽ç¥å符大å°åã
å½åå®è£ ç C æ¬å°ç¯å¢å¯è½æ¥åå¦å¤çæ°åæ ¼å¼ã
è¥ base 为 â0â ï¼åèªå¨æ£æµæ°å¼è¿å¶ï¼è¥åç¼ä¸º 0 ï¼ååºä¸ºå
«è¿å¶ï¼è¥åç¼ä¸º 0x æ 0X ï¼ååºä¸ºåå
è¿å¶ï¼å¦ååºä¸ºåè¿å¶ã
è¥ç¬¦å·æ¯è¾å ¥åºåçä¸é¨åï¼å坹仿°ååºå计ç®å¾æ¥çæ°åå¼ååï¼å¦åç¨ç»æç±»åçä¸å åï¼å®å¯¹æ ç¬¦å·æ´æ°åºç¨åå·è§åã
è¥ pos 䏿¯ç©ºæéï¼å转æ¢å½æ°å
é¨ç ptr æé伿¥æ¶é¦ä¸ª str.c_str() 䏿ªè½¬æ¢å符çå°åï¼ç¶å该å符ç䏿 å¨è®¡ç®ååå¨äº *pos ï¼ç»åºè½¬æ¢æå¤ççå符æ°ã
åæ°
| str | - | è¦è½¬æ¢çå符串 |
| pos | - | åå¨è¢«å¤çå符æ°çæ´æ°çå°å |
| base | - | æ°ååºåº |
è¿åå¼
转æ¢å°æå®æ ç¬¦å·æ´æ°ç±»åçå符串ã
å¼å¸¸
- è¥ä¸è½è¿è¡è½¬æ¢åæåº std::invalid_argument
- è¥è½¬æ¢å¼ä¼è½å¨è½¬æ¢ç±»åçèå´ä¹å¤ï¼æåºå±å½æ°ï¼ std::strtoul æ std::strtoull ï¼è®¾ errno 为 ERANGE åæåº std::out_of_range ã
åé
| (C++11)(C++11)(C++11) |
转æ¢å符串为æç¬¦å·æ´æ° (彿°) |
| (C++11)(C++11)(C++11) |
转æ¢å符串为浮ç¹å¼ (彿°) |