About 3,390,000 results
Open links in new tab
  1. c++ - String to float using stringstream - Stack Overflow

    Oct 18, 2012 · Actually, the simplest way to do string to float conversion is probably boost::lexical_cast. std::string const s = "120.34"; try { float f = boost::lexical_cast<float>(s); } …

  2. C++ String to Float/Double and Vice-Versa - GeeksforGeeks

    Apr 26, 2025 · In this article, we will learn how to convert String To Float/Double And Vice-Versa. In order to do conversion we will be using the following C++ functions: std::stof() – convert …

  3. converting string to float in c++ - Stack Overflow

    Do neither and use stringstream. std::stringstream s(str_val); float f; if (s >> f) { // conversion ok } else { // conversion not ok }

  4. c++ - conversion from empty string to float using stringstream results ...

    Aug 26, 2013 · std::stringstream ss; float a; float b; for(int i=0; i<LIM; ++i){ //some other conversions using same stringstream //clearing stringstream ss.str( std::string() ); ss.clear(); ss …

  5. stringstream in C++ and its Applications - GeeksforGeeks

    Jan 11, 2025 · A stringstream associates a string object with a stream allowing you to read from the string as if it were a stream (like cin). To use stringstream, we need to include sstream …

  6. How to Convert String to Float/Double in C++

    We can use the C++11 to_string() function to convert a floating-point number to a string. Let’s look at the example below: #include <iostream> #include <string> int main() { float num_float = …

  7. Convert String to Floating Point Number in C++ - Online …

    Oct 19, 2022 · There are several ways to convert strings to floating point numbers. The first two methods, using stringstream and sscanf(), are the generic ways to convert a string to any …

  8. Convert String to Float in C++: A Quick Guide - cppscripts.com

    There are several methods available in C++ to convert strings to floats, but two of the most commonly used approaches are `std::stof` and `std::istringstream`. Using `std::stof` `std::stof` …

  9. [C++]Converting string to floats; can't clear stringstream ... - Reddit

    Feb 13, 2017 · std::copy(std::istream_iterator<std::string>(infile), std::istream_iterator<std::string>(), std::back_inserter(myvector)); and then use C's strtof per …

  10. c - How to convert string to float? - Stack Overflow

    Oct 31, 2011 · By using sscanf we can convert string to float. #include<stdio.h> #include<string.h> int main() { char str[100] ="4.0800" ; const char s[2] = "-"; char *token; …

  11. Some results have been removed
Refresh