Search notes:

Create a std::string representation of a numerical value with std::to_string (C++ Standard Library)

std::string takes a numerical value as input parameter and returns a std::string that represents the numerical value.
//
//   g++ -std=c++11 to_string.cpp
//
#include <string>
#include <iostream>

int main() {

  std::string res;

  bool   b = true        ; res = std::to_string(b); std::cout << res << std::endl; // 1
  float  f = 123.45678901; res = std::to_string(f); std::cout << res << std::endl; // 123.456787
  double d = 123.45678901; res = std::to_string(d); std::cout << res << std::endl; // 123.456789
  long   l = 123456789012; res = std::to_string(l); std::cout << res << std::endl; // 123456789012

}
Github repository about-cpp-standard-library, path: /string/to_string.cpp

See also

C++ Standard Library

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1740377681, '3.144.106.95', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/CPP-Standard-Library/string/to_string(56): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78