C Standard Libraries C++

atol()

Declaration

long atol(const char*);

Description

Takes in a number as a null-terminated char string and returns the value as a long.

Example

#include <iostream>
#include <cstdlib>

int main() {
    using namespace std;

    char caNullTermString[] = "2";
    long lA = atol(caNullTermString);
    long lB = atol("4");

    cout << (lA + lB) << endl;

    return 0;
}

Output

atol() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.