ATOI()
this function is used to convert strings into integer (int) numeric values for further processing. this is useful when processing numeric input provided as strings, such as command-line arguments or user input.
int num = atoi("12345");
* "12345" is converted to the integer 12345
#include <stdio.h>
#include <stdlib.h>
int main() {
char intStr[] = "456";
char floatStr[] = "98.76";
// Convert string to integer
int num = atoi(intStr);
// Convert string to floating-point number
double val = atof(floatStr);
printf("Integer value: %d\n", num);
printf("Floating-point value: %.2f\n", val);
return 0;
}
Last updated