Demonstration of atof(). - C String

C examples for String:String Function

Description

Demonstration of atof().

Demo Code

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

int main( void )
{
    char buf[80];
    double d;//from w w  w .java2s .  co  m

    while (1)
    {
        printf("\nEnter the string to convert (blank to exit):     ");
        gets_s(buf);

        if ( strlen(buf) == 0 )
            break;

        d = atof( buf );

        printf("The converted value is %f.", d);
    }
    return 0;
}

Result


Related Tutorials