Open In App

strtof function in C

Last Updated : 22 Jul, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

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.

Syntax:

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.





Output:

365.25
7.0
One year has 52.18 weeks


Next Article
Article Tags :

Similar Reads