Using atoi to convert string to int - C++ Data Type

C++ examples for Data Type:int

Description

Using atoi to convert string to int

Demo Code

#include <iostream> 
#include <cstdlib> // atoi prototype 
using namespace std; 

int main() /*from   ww w  . j av a 2 s .c  o m*/
{ 
    int i = atoi( "1234" ); // convert string to int 

    cout << "The string \"1234\" converted to int is " << i << "\nThe converted value minus 111 is " << i - 111 << endl; 
}

Result


Related Tutorials