ATOI(3) BSD Library Functions Manual ATOI(3)NAME
atoi, atoi_l -- convert ASCII string to integer
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdlib.h>
int
atoi(const char *str);
#include <xlocale.h>
int
atoi_l(const char *str, locale_t loc);
DESCRIPTION
The atoi() function converts the initial portion of the string pointed to by str to int representation.
It is equivalent to:
(int)strtol(str, (char **)NULL, 10);
While the atoi() function uses the current locale, the atoi_l() function may be passed a locale directly. See xlocale(3) for more informa-
tion.
IMPLEMENTATION NOTES
The atoi() function is not thread-safe and also not async-cancel safe.
The atoi() function has been deprecated by strtol() and should not be used in new code.
ERRORS
The function atoi() need not affect the value of errno on an error.
SEE ALSO atof(3), atol(3), strtod(3), strtol(3), strtoul(3), xlocale(3)STANDARDS
The atoi() function conforms to ISO/IEC 9945-1:1990 (``POSIX.1''), ISO/IEC 9899:1990 (``ISO C90''), and ISO/IEC 9899:1999 (``ISO C99'').
BSD June 4, 1993 BSD
Check Out this Related Man Page
ATOF(3) BSD Library Functions Manual ATOF(3)NAME
atof, atof_l -- convert ASCII string to double
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdlib.h>
double
atof(const char *str);
#include <xlocale.h>
double
atof_l(const char *str, locale_t loc);
DESCRIPTION
The atof() function converts the initial portion of the string pointed to by str to double representation.
It is equivalent to:
strtod(str, (char **)NULL);
The decimal point character is defined in the program's locale (category LC_NUMERIC).
While the atof() function uses the current locale, the atof_l() function may be passed a locale directly. See xlocale(3) for more informa-
tion.
IMPLEMENTATION NOTES
The atof() function is not thread-safe and also not async-cancel-safe.
The atof() function has been deprecated by strtod() and should not be used in new code.
ERRORS
The function atof() need not affect the value of errno on an error.
SEE ALSO atoi(3), atol(3), strtod(3), strtol(3), strtoul(3), xlocale(3)STANDARDS
The atof() function conforms to ISO/IEC 9945-1:1990 (``POSIX.1''), ISO/IEC 9899:1990 (``ISO C90''), and ISO/IEC 9899:1999 (``ISO C99'').
BSD June 4, 1993 BSD
i know what is the use of atoi function....
converts string to int.
but whenever i use that it gives me 0....
could any one help in this issue..
eg.
int i;
char str;
str="name";
i=atoi(str);
i gives me 0. why? (3 Replies)
Hi,
I'm trying to locate where on the filesystem I can find the source code for C standard libraries. The reason why is I'd like to look at the implementation of "'atoi"'. I've tried a brutal search of "grep -r "atoi" *" from root as root but the search took too long.
I'm running redhat 7.3... (3 Replies)
I have a PORT_NUM macro (10 digits long number)
in a server file, if i do
htons(PORT_NUM)
i get
warning: this decimal constant is unsigned only in ISO C90
warning: large integer implicitly truncated to unsigned type
whats wrong with this? (2 Replies)
In the book "The C programming language"; second edition, chapter 2.7 there is a snippet which is supposed to:
"convert a string of digits into its numeric equivalent".
int atoi(char s)
{
int i, n;
n = 0;
for ( i = 0; s >= '0' && s <= '9'; ++i)
n = 10 * n + (s -... (4 Replies)