Parses the C-string str(assumed) interpreting its content as a floating-point number (according to the current locale ) and returns its value as a float. If endptr(end pointer) is not a null pointer, the function also sets the value of endptr to point to the first character after the number.
strtof(const char* str, char **endptr) Parameters: str : String object with the representation of floating point number endptr : Reference to an already allocated object of type char*, whose value is set by the function to 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.
365.25 7.0 One year has 52.18 weeks
This article is contributed by Mohak Agrawal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- How to call function within function in C or C++
- arc function in C
- Inline function in C
- putchar() function in C
- mbsrtowcs() function in C/C++
- mbrlen() function in C/C++
- strcmpi() function in C
- wcstod() function in C/C++
- wcstol() function in C/C++
- wcsrtombs() function in C/C++
- wcsncat() function in C/C++
- wcsncmp() function in C/C++
- wcrtomb() function in C/C++
- vswprintf() function in C/C++
- wmemchr() function in C/C++
- wmemcmp() function in C/C++
- wcstoul() function in C/C++
- atexit() function in C/C++
- strcspn() function in C/C++
- strrchr() function in C/C++
Improved By : nidhi_biet