ATOF()
this function is used to used to convert strings into floating-point (double) numeric values for further processing. this is useful when processing numeric input provided as strings, such as command-line arguments or user input.
double pi = atof("3.14159");
* "3.14159" is converted to the double 3.14159
#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