Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the numerical conversion function method of the string of Clipper 11?

Shulou Source: shulou.com Published: 2022-06-01 19:19:22 10月01日 Update

This article mainly introduces "C++11 string numerical conversion function method is what", in daily operation, I believe many people in C++11 string numerical conversion function method is what problem there are doubts, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, hope to answer "C++11 string numerical conversion function method is what" doubts help! Next, please follow the small series to learn together!

String is the most commonly used class in the standard library, active in various scenarios of string processing. But the conversion between string and numeric has long been cumbersome. This situation has changed considerably since C++11, because the standard library provides a set of functions for converting strings to values.

Value to string

The function is very simple and straightforward, requiring only one function: to_string. But it's actually a set of overloaded functions that convert int, long, long long, unsigned int, unsigned long, float, double, long double to string.

It is also very simple to use:

string value = to_string(2.5);

string to value

C++11 provides conversion methods for basic numeric types.

stoi: string to int

bol: string to long

stoll: string to long long

Stoul: sting to unsigned long

stoul: string to unsigned long.

stof: string to float

stod: string to double

stold: string to long double.

Here is the sample code:

string value = to_string(2.5);

int iv = stoi(value);

cout

Tags: Numeric values functions methods parameters results learning characters three code strings integers more standards processing help practical great bright tedious next Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL NVidia OPPO Reno Xiaomi