Prev Next
C itoa () function:
- itoa () function in C language converts int data type to string data type. Syntax for this function is given below.
char * itoa ( int value, char * str, int base );
- “stdlib.h” header file supports all the type casting functions in C language. But, it is a non standard function.
Example program for C itoa () function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int a=54325; char buffer[20]; itoa(a,buffer,2); // here 2 means binary printf("Binary value = %s\n", buffer); itoa(a,buffer,10); // here 10 means decimal printf("Decimal value = %s\n", buffer); itoa(a,buffer,16); // here 16 means Hexadecimal printf("Hexadecimal value = %s\n", buffer); return 0; } |
itoa () function Output:
Binary value = 1101010000110101
Decimal value = 54325
Hexadecimal value = D435
|
Other inbuilt typecast functions in C programming language:
- Typecasting functions in C language performs data type conversion from one type to another.
- itoa() function converts int data type to string data type.
- Click on each function name below for description and example programs.
Typecast function | Description |
atof() |
atof( ) function converts string to float |
atoi() |
atoi( ) function converts string to int |
atol() |
atol( ) function converts string to long |
itoa() |
itoa( ) function converts int to string |
ltoa() |
ltoa( ) function converts long to string |