2.1.6.3 atoi


Description

Converts string to an integer.

Syntax

int atoi( LPCSTR lpcsz )

Parameters

lpcsz
[input] the string to convert.

Return

an integer value. If conversion can not be made, zero is returned.

Examples

EX1

// This is a self contained sample program for the function atoi, 
// To run the program, enter the following command in the Script window:
//   atoi_ex1
// When it runs, the following meassages will be printed:
//   Converted "-123" to -123
//   Converted "3.45" to 3
//   Converted "abc" to 0
//
void    atoi_ex1()
{
    int    ii;
    
    char    sz1[] = "-123";
    ii = atoi(sz1);
    printf("Converted \"%s\" to %d\n", sz1,ii);
    
    char    sz2[] = "3.45";
    ii = atoi(sz2);
    printf("Converted \"%s\" to %d\n", sz2,ii);
    
    char    sz3[] = "abc";
    ii = atoi(sz3);
    printf("Converted \"%s\" to %d\n", sz3,ii);
    
}

Remark

Converts string to an integer.

See Also

Atol

Header to Include

origin.h

Reference