Overview :

The "atof" is a macro which convert a string to the floating value.

Syntax :
double atof(cont char *x);
Description :

The "atof" function accepts 1 parameters

  • char *x -> It is a pointer which points to the string which is to converted into floating point value.

  • The function returns the converted string which is an floating value

  • The function returns 0 if string cannot be converted

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

int main()
   float f;
   char *str = "243";
   f = atof(str);
   printf("string = %s float = %f\n", str, f);
   return 0;


comments powered by Disqus