[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/string/basic_string/stol [Back]  [Original]

std::stoi, std::stol, std::stoll cppreference.com
cppreference.com

std::stoi, std::stol, std::stoll

cppreference.com
 
C++
(C++20)
(C++20)
(C++11)
(C++20)
/
(C++11)
(C++11)
(C++11)
(C++17)
 
 
std::basic_string
-
(C++17)
,
/
( C++20)( C++20)( C++20)( C++20)( C++20)(C++20)
(C++11)(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
 
<tbody> </tbody>
int stoi( const std::string& str, size_t *pos = 0, int base = 10 );
(1) ( C++11)
long stol( const std::string& str, size_t *pos = 0, int base = 10 );
(2) ( C++11)
long long stoll( const std::string& str, size_t *pos = 0, int base = 10 );
(3) ( C++11)

str.

( std::isspace) , , -n ( n=base) . :

  • ()
  • () (0), (, 8 0)
  • () (0x 0X), (, 16 0)
  • .

{0,2,3,...,36}. 2 {0,1}, 3 {0,1,2}, . , 10, , Aa 11, Zz 36. .

C.

base 0, : 0, , 0x 0X, , .

, , , , .

pos. pos NULL, .

str
pos
base

, .

#include <iostream>
#include <string>

int main()
{
    std::string test = "45";
    int myint = stoi(test);
    std::cout << myint << '\n';
}

:

45

.


() []
(C++11)(C++11)

() []
(C++11)(C++11)(C++11)

() []
(C++11)
string
() []

Web Proxy Viewer  |  New URL  |  Original Page