C atof() function

The atof() function is used to converts string data type to float data type. The syntax for atof() is as follows :
 double atof( const char * string );
Where str is the string you want to convert.

Example :
#include <stdio.h>
#include <stdlib.h>

int main() {
  char str[] = "56.876";
  float num = atof(str);
  printf("Value of num is : %.3f\n", num);
  return 0;
}
Output :

Value of num is : 56.876

Note : The atof() function is predefined on the "stdlib.h" standard library file.

Next : C Language Tutorials List