![]() |
![]() |
![]() |
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:
![]() |
![]() |
![]() |
| Home | | | Reference | | | Play Games! | | | Blog | | | Forum | | | Site Map | | | Contact Us |





