Prev Next
C atoi() function:
- atoi() function in C language converts string data type to int data type. Syntax for atoi() function is given below.
int atoi (const char * str);
- “stdlib.h” header file supports all the type casting functions in C language.
Example program for C atoi() function:
1 2 3 4 5 6 7 8 9 10 |
#include <stdio.h> #include <stdlib.h> int main() { char a[10] = "100"; int value = atoi(a); printf("Value = %d\n", value); return 0; } |
Output:
Value = 100
|
Other inbuilt typecast functions in C programming language:
- Typecasting functions in C language performs data type conversion from one type to another.
- Click on each function name below for description and example programs.
Typecast function | Description |
atof() | Converts string to float |
atoi() | Converts string to int |
atol() | Converts string to long |
itoa() | Converts int to string |
ltoa() | Converts long to string |