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.
- Generate a random permutation of elements from range [L, R] (Divide and Conquer)
- Passing and Returning Objects in C++
- Train a Support Vector Machine to recognize facial features in C++
- Salesforce Interview Experience | On-Campus for FTE
- unordered_set operators in C++ STL
- Dividing a Large file into Separate Modules in C/C++, Java and Python
- How to delete a range of values from the List using Iterator
- How to create a List with Constructor in C++ STL
- How to delete last element from a List in C++ STL
- Can C++ reference member be declared without being initialized with declaration?
- Finding Floor and Ceil of a Sorted Array using C++ STL
- Some useful C++ tricks for beginners in Competitive Programming
- Replace each node with its Surpasser Count in Linked List
- Comparison of Java with other programming languages
- Print multiples of Unit Digit of Given Number