atof() in C++

atof(): This function is available in the file stdlib.h. This function converts the given string to double. This function parses the C string str, interpreting its content as a floating-point number, and returns its value as a double.

Parameters: One parameter is required for this function.

str: A string that is to be converted into a double value.

Syntax:

atof(str)

For Example:

atof("123.12") = > It returns 123.12

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    char str[] = "123.12";

    cout << atof(str<< "\n";

    return 0;
}


No comments:

Post a Comment