To convert an integer to a string in C , use the std::to_string function:
std::string intToString = std::to_string(123);
To convert a string to an integer, use the std::stoi function:
int stringToInt = std::stoi("456");
For floating-point numbers, use the std::to_string function:
std::string floatToString = std::to_string(12.34);
To convert a string to a floating-point number, use the std::stof function:
float stringToFloat = std::stof("56.78");
The above is the detailed content of How to Convert Numbers and Strings in C ?. For more information, please follow other related articles on the PHP Chinese website!