C++ Programming/Code/Standard C Library/Functions/atoi

atoi
The atoi function converts str into an integer, and returns that integer. str should start with a whitespace or some sort of number, and atoi will stop reading from str as soon as a non-numerical character has been read. For example:

All five of the above assignments to the variable i would result in it being set to 512.

If the conversion cannot be performed, then atoi will return zero:

A complete C++ implementation of atoi.


 * Related topics: atof - atol (Standard C I/O) sprintf