C++ USES stringstream for data type conversion instances

  • 2020-04-02 02:58:41
  • OfStack

This article illustrates an example of C++ using stringstream for data type conversion. Share with you for your reference. Specific analysis is as follows:

In the C++ standard library, stringstream can be used to convert between various data types

So string to int

std::string strId = "1";  
int id = 0; 
std::stringstream ss; 
ss << strId.c_str(); 
ss >> id;

Hope that the article described in the C++ programming to help you.


Related articles: