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. C // C code to convert string having // floating point as its content // using strtof function #include <stdio.h> #include <stdlib.h> // Header file containing strtof function int main() { // Character array to be parsed char array[] = "365.25 7.0"; // Character end pointer char* pend; // f1 variable to store float value float f1 = strtof(array, &pend); // f2 variable to store float value float f2 = strtof(pend, NULL); // Printing parsed float values of f1 and f2 printf("%.2f\n%.2f\n", f1, f2); // Performing operation on the values returned printf(" One year has %.2f weeks \n", f1 / f2); return 0; } Output: 365.25 7.0 One year has 52.18 weeks Comment More infoAdvertise with us Next Article strtof function in C M Mohak Agrawal Improve Article Tags : Misc C Language C-Library Practice Tags : Misc Similar Reads strol() function in C++ The strtol() function in C++ interprets the contents of a string as an integral number of the specified base and return its value as a long int.This function also sets an end pointer that points to the first character after the last valid numeric character of the string, if there is no such characte 3 min read strtod() function in C/C++ The strtod() is a builtin function in C and C++ STL which interprets the contents of the string as a floating point number and return its value as a double. It sets a pointer to point to the first character after the last valid character of the string, only if there is any, otherwise it sets the poi 4 min read strtol() function in C++ STL The strtol() function is a builtin function in C++ STL which converts the contents of a string as an integral number of the specified base and return its value as a long int. Syntax: strtol(s, &end, b) Parameters: The function accepts three mandatory parameters which are described as below: s: s 4 min read strlen() function in c The strlen() function in C calculates the length of a given string. The strlen() function is defined in string.h header file. It doesn't count the null character '\0'. Syntax of C strlen() The syntax of strlen() function in C is as follows: size_t strlen(const char* str);Parameters The strlen() func 1 min read strrev() function in C The strrev() function is a built-in function in C and is defined in string.h header file. The strrev() function is used to reverse the given string. Syntax:char *strrev(char *str);Parameter:str: The given string which is needed to be reversed.Returns: This function doesn't return anything but the re 2 min read strcmpi() function in C The strcmpi() function is a built-in function in C and is defined in the "string.h" header file. The strcmpi() function is same as that of the strcmp() function but the only difference is that strcmpi() function is not case sensitive and on the other hand strcmp() function is the case sensitive. Sy 2 min read strftime() function in C/C++ strftime() is a function in C which is used to format date and time. It comes under the header file time.h, which also contains a structure named struct tm which is used to hold the time and date. The syntax of strftime() is as shown below : size_t strftime(char *s, size_t max, const char *format, c 3 min read strcspn() function in C/C++ The strcspn() function in C/C++ takes two string as input, string_1 and string_2 as it's argument and searches string_1 by traversing for any characters that is present in string_2 . The function will return the length of string_1 if none of the characters of string_2 are found in string_1 . This fu 2 min read isdigit() Function in C The isdigit() in C is a built-in function that is used to check if the given character is a numeric digit or not. It is defined inside <ctype.h> header file. In this article we will learn how to use isdigit() function in C.Syntaxisdigit(arg)Parametersarg: Character which we have to check.Retur 2 min read tmpfile() function in C In C Programming Language, the tmpfile() function is used to produce/create a temporary file. tmpfile() function is defined in the "stdio.h" header file. The created temporary file will automatically be deleted after the termination of program. It opens file in binary update mode i.e., wb+ mode. The 1 min read Like