Main Page | Alphabetical List | Class List | File List | Class Members | File Members

strtol.h File Reference

definition of the strtol() and strtoll() functions More...

#include <nlibc.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>

Include dependency graph for strtol.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define strtoll(nptr, endptr, base)   strtol(nptr, endptr, base)

Functions

long strtol (const char *nptr, char **endptr, int base)
 Convert a string to a long integer.
.


Detailed Description

definition of the strtol() and strtoll() functions

SOURCE
NetBSD
strtol.c,v 1.15 1999/09/20 04:39:42 lukem Exp
COPYRIGHT
Copyright (c) 1990, 1993 The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the University of California, Berkeley and its contributors. 4. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file strtol.h.


Define Documentation

#define strtoll nptr,
endptr,
base   )     strtol(nptr, endptr, base)
 

Definition at line 225 of file strtol.h.


Function Documentation

long strtol const char *  nptr,
char **  endptr,
int  base
 

Convert a string to a long integer.
.

NAME
strtol - convert a string to a long integer.
strtoll - convert a string to a long long integer.

SYNOPSIS
#include <stdlib.h>

long int strtol(const char *nptr, char **endptr, int base);
long long int strtoll(const char * restrict nptr,
char ** restrict endptr, int base);

DESCRIPTION
The strtol() function converts the string in nptr to a
long integer value according to the given base, which must
be between 2 and 36 inclusive, or be the special value 0.

The string must begin with an arbitrary amount of white
space (as determined by isspace(3)) followed by a single
optional `+' or `-' sign. If base is zero or 16, the
string may then include a `0x' prefix, and the number will
be read in base 16; otherwise, a zero base is taken as 10
(decimal) unless the next character is `0', in which case
it is taken as 8 (octal).

The remainder of the string is converted to a long int
value in the obvious manner, stopping at the first charac­
ter which is not a valid digit in the given base. (In
bases above 10, the letter `A' in either upper or lower
case represents 10, `B' represents 11, and so forth, with
`Z' representing 35.)

If endptr is not NULL, strtol() stores the address of the
first invalid character in *endptr. If there were no dig­
its at all, strtol() stores the original value of nptr in
endptr (and returns 0). In particular, if *nptr is not
`\0' but **endptr is `\0' on return, the entire string is
valid.

RETURN VALUE
The strtol() function returns the result of the conver­
sion, unless the value would underflow or overflow. If an
underflow occurs, strtol() returns LONG_MIN. If an over­
flow occurs, strtol() returns LONG_MAX. In both cases,
errno is set to ERANGE.

ERRORS
ERANGE The given string was out of range; the value con­
verted has been clamped.

IMPLEMENTATION for APEnext:
done
Ignores `locale' stuff. Assumes that the upper and lower case
alphabets and digits are each contiguous.
strtoll() is identical to strtol() since long and long long have
the same size.


Generated on Mon Feb 20 15:54:52 2006 for nlibc by doxygen 1.3.5