Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualServant of the Lord

Posted 15 February 2013 - 10:20 PM

C++11 introduced some new conversion functions for that exact purpose:

 

std::to_string() - Integers and float-types to std::string.

 

Also:

std::stoi() - std::string to int

std::stol() - std::string to long

std::stoul() - std::string to unsigned long

std::stof() - std::string to float

std::stod() - std::string to double

 

The function-name format is:

stof

s <to> f

string <to> float

 

Just like the pre-existing atoi() (where 'a' is for ASCII, 'char*' raw-string functions)

 

This is different from strtof() and the like. I have no clue what those functions do. smile.png

([Edit:] Ah, here's an explanation of strtof. I never knew about that function)


#2Servant of the Lord

Posted 15 February 2013 - 10:17 PM

C++11 introduced some new conversion functions for that exact purpose:

 

std::to_string() - Integers and float-types to std::string.

 

Also:

std::stoi() - std::string to int

std::stol() - std::string to long

std::stoul() - std::string to unsigned long

std::stof() - std::string to float

std::stod() - std::string to double

 

The function-name format is:

stof

s <to> f

string <to> float

 

Just like the pre-existing atoi() (where 'a' is for ASCII, 'char*' raw-string functions)

 

This is different from strtof() and the like. I have no clue what those functions do. smile.png


#1Servant of the Lord

Posted 15 February 2013 - 10:15 PM

C++11 introduced some new conversion functions for that exact purpose:

 

std::to_string() - Integers and float-types to std::string.

 

Also:

std::stoi() - std::string to int

std::stol() - std::string to long

std::stoul() - std::string to unsigned long

std::stof() - std::string to float

std::stod() - std::string to double

 

The function-name format is:

stof

s <to> f

string <to> float

 

Just like the pre-existing atoi() (where 'a' is for ASCII, 'char*')

 

Just don't mix it up with strtof() and the like. I have no clue what those functions do. smile.png


PARTNERS