Parses string interpreting its content as a floating-point number, which is returned as a value of type float.
float stof (const string& str, size_t* idx = 0); float stof (const wstring& str, size_t* idx = 0); Parameters : str : String object with the representation of a floating-point number. idx : Pointer to an object of type size_t, whose value is set by the function to position of the next character in str after the numerical value. This parameter can also be a null pointer, in which case it is not used. Return Value : On success, the function returns the converted floating-point number as a value of type float.
Below is the C++ implementation of std::stof :
This article is contributed by Rohit Thapliyal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Maximum absolute difference in an array
- Count the pairs of vowels in the given string
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- Print path from root to all nodes in a Complete Binary Tree
- Count the number of 1's and 0's in a binary array using STL in C++ ?
- Find elements of an Array which are Odd and Even using STL in C++
- Find elements of an array which are divisible by N using STL in C++
- All reverse permutations of an array using STL in C++
- Generics in C++
- Find the longest subsequence of an array having LCM at most K
- Maximum Subarray Sum after inverting at most two elements
- Maximum element in a sorted and rotated array
- What does main() return in C and C++?
- SDL library in C/C++ with examples