Prev Next
- 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 atoi() function in C:
#include <stdio.h> #include <stdlib.h> int main() { char a[10] = "100"; int value = atoi(a); printf("Value = %dn", value); return 0; }
Output:
Value = 100
|
……
Other inbuilt typecasting functions in C 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.
S.no | Typecast function | Description |
1 | atof() | Converts string to float |
2 | atoi() | Converts string to int |
3 | atol() | Converts string to long |
4 | itoa() | Converts int to string |
5 | ltoa() | Converts long to string |
Prev Next
.