atoi function(Convert String to Integer) in C Language – example and detail

In the C Programming Language, the atoi characteristic converts a string to an integer.

The atoi feature skips all white-space characters at the starting of the string, converts the subsequent characters as section of the number, and then stops when it encounters the first personality that is not a number.

Syntax

The syntax for the atoi function in the C Language is:

int atoi(const char *nptr);

Parameters or Arguments

nptr A pointer to a string to convert to an integer.

Returns

The atoi feature returns the integer representation of a string. The atoi feature skips all white-space characters at the beginning of the string, converts the subsequent characters as phase of the number, and then stops when it encounters the first character that isn’t always a number.

Required Header

In the C Language, the required header for the atoi feature is:

#include <stdlib.h>

Applies To

In the C Language, the atoi function can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C features that are similar to the atoi function:

atof characteristic atol function strtol feature strtoul characteristic

See Also

Other C functions that are noteworthy when dealing with the atoi function:

strtod function <stdlib.h>