atoi of a string code example
Example 1: atoi
#include <stdlib.h> //atoi's library
#include <stdio.h>
int main (void)
{
string input = "9";
int output = atoi(input);
printf("%i", output);
//this will print out 9 as an int not a string
}
Example 2: what is atoi in strinf
The C library function int atoi(const char *str) converts the
string argument str to an integer (type int).
Note: It is used in case of string because in strings a number is
also stored as char and we have to do Typecasting form (string -> int)