atof
Syntax:
#include <stdlib.h> double atof( const char *str ); The function atof() converts str into a double, then returns that value. str must start with a valid number, but can be terminated with any non-numerical character, other than "E" or "e". For example, x = atof( "42.0is_the_answer" ); results in x being set to 42.0. |
#include <stdlib.h> int atoi( const char *str );
The atoi() function converts str into an integer, and returns that integer. str should start with some sort of number, and atoi() will stop reading from str as soon as a non-numerical character has been read. For example,
i = atoi( "512.035" );
would result in i being set to 512.
You can use (Standard C I/O) sprintf() to convert a number into a string.