Table of Contents
Previous topic Next topic
C COMPILER LIBRARY FUNCTION REFERENCE->Detailed Descriptions->atoi() atol() atof()atolf()
Summary
#include <stdlib.h>
int atoi(const char* string); | Convert string to int |
long atol(const char* string); | Convert string to long |
double atof(const char* string); | Convert string to double |
long double atolf(const char* string); | Convert string to long double |
Parameter
string A pointer to the string to be converted.
Description
These functions convert a character string to an integer value (atoi()), a long integer value (atol()), a double precision floating point value (atof()) or a long double precision floating point value.
With atoi() and atol():
After skipping any white space at the beginning of the string, the first character may be +, or a decimal digit. The rest of the string is then read until a character is encountered that is not a decimal digit. This may be the null character.
With atof() and atolf():
After skipping any white space at the beginning of the string, the following format is expected:
[sign][digits][.digits][E or e][sign][digits]
Conversion terminates when a character is found that does not fit this format. This may be the null character.
Return Value
These functions return the number produced by interpreting the input string as a decimal number. Note that no overflow check is carried out and if overflow occurs, then the return value is undefined. Zero is returned if no conversion takes place.