Home
menubar
rss_feed

Previous Reference C++ Reference <cstdlib> Next Reference




C++ Reference: atoi()





atoi()


Declaration

int atoi(const char*);

Description

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

Example

#include <iostream>
#include <cstdlib>

int main() {
    using namespace std;

    char caNullTermString[] = "2";
    int iA = atoi(caNullTermString);
    int iB = atoi("4");

    cout << (iA + iB) << endl;

    return 0;
}


Output:








Previous Reference C++ Reference <cstdlib> Next Reference




Home | Reference | Play Games! | Blog | Forum | Site Map | Contact Us


shadow bottom image