atol() in C++

atol(): This function is available in the file stdlib.h. This function Convert string to a long integer. This function parses the C-string str interpreting its content as an integral number and returned as a value of type long int.A string may contain other characters than digits, it ignores them and converts the value into long int till the digits in the string.

Parameters: One parameter is required for this function.

str: A string that is converted into the long int.

Syntax:

atol(str)

For Example:

atol("123444.23") = > It returns 123444.23

Approach

C++

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

int main()
{

    char str[] = "123444.23";
    cout << atol(str<< "\n";

    return 0;
}


No comments:

Post a Comment