Converting between types
C++ Conversions between integers and strings
Last Update Unknown
From integer to string
The to_string function is used to convert a numerical value to string.
Returns a string object containing the representation of val as a sequence of characters.
From string to integer
The stoi function is used to convert strings to integers.
On success, the function returns the converted integral number as an int value.
If no conversion could be performed, an invalid_argument exception is thrown.
More conversions from strings
stoi | Convert string to integer |
stol | Convert string to long int |
stoul | Convert string to unsigned integer |
stoll | Convert string to long long |
stoull | Convert string to unsigned long long |
stof | Convert string to float |
stod | Convert string to double |
stold | Convert string to long double |