lundi 9 septembre 2019

What is difference between std::stof and atof when each one should be used?

I have read some documents about each, for example

http://www.cplusplus.com/reference/string/stof/

http://www.cplusplus.com/reference/cstdlib/atof/

I undrstand that atof is part of <cstdlib> and has const char* as input parameter and std::stof is part of std::string and has different input format.

But not clea,

  • can they be used interchangeably
  • does they convert to same float value with same input
  • which is scenario best to use for each of these

Aucun commentaire:

Enregistrer un commentaire