“stdlib.h” header file supports all the type casting functions in C language. But, it is a non standard function. Example program for itoa function in C. 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.
< C++ Programming | Code/Standard C Library | Functions
atoi[edit]
Syntax |
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:
C Programming Atoi
A complete C++ implementation of atoi.
- Related topics
- atof - atol
(Standard C I/O) sprintf
Atoi C++ String
Retrieved from 'https://en.wikibooks.org/w/index.php?title=C%2B%2B_Programming/Code/Standard_C_Library/Functions/atoi&oldid=3676456'