atof() string to real conversion - C-Tutorial

Latest

Saturday, 8 October 2016

atof() string to real conversion

 atof() function:         atof() function converts a string of digits into a real value.  The general format of the atof() function is:


                        Syntax:           float atof(string);

            Function accepts a string as an argument and returns the result value as a real value.

/* EXAMPLE PROGRAM FOR atof() FUNCTION*/

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

main()
{
    char a[10] = "3.14";
    printf("Value of pi = %f \n", atof(a));

}

No comments:

Post a Comment