c++ atoi reference code example
Example: atoi c++
Parses the C-string str interpreting its content as an integral number
If the converted value would be out of the range of representable
values by an int, it causes undefined behavior.
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int i;
char buffer[256];
printf ("Enter a number: ");
fgets (buffer, 256, stdin);
i = atoi (buffer);
printf ("The value entered is %d. Its double is %d.\n",i,i*2);
return 0;
}
Enter a number: 73
The value entered is 73. Its double is 146.