| Table of Contents | Previous | Next |
The header <stdlib.h> declares functions for
number conversion, storage allocation, and similar tasks.
atof converts s to
double; it is equivalent to strtod(s, (char **)NULL).
s converted to double.
s to int; it is equivalent to
(int)strtol(s, (char
**)NULL, 10).
s converted to int.
s to long; it is equivalent to
strtol(s, (char **)NULL, 10).
s converted to long.
s to double,
ignoring leading white space; it stores a pointer to any
unconverted suffix in *endp unless
endp is NULL.
HUGH_VAL is returned
with the proper sign; if the answer would underflow, zero is
returned. In either case, errno is set to
ERANGE.
s to long,
ignoring leading white space; it stores a pointer to any
unconverted suffix in *endp unless
endp is NULL. If base is between
2 and 32 , conversion is done assuming that the input is
written in that base. If base is zero, the
base is 8, 10, or 16; leading 0 implies octal and leading
0x or 0X hexadecimal. Letters
in either case represent digits from 10 to base-1;
a leading 0x or 0X is permitted in
base 16.
s as explained above.
If the answer would overflow, LONG_MAX or
LONG_MIN is returned, depending on the sign of the
result, and errno is set to ERANGE.
strtoul is the same as strtol
except that the result is unsigned long and the error
is ULONG_MAX
s as explained above.
If the answer would overflow, ULONG_MAX is
returned and errno is set to ERANGE.
rand generates a pseudo-random integer in the range
0 to RAND_MAX, which is at least 32767.
RAND_MAX.
srand uses seed as the seed for a new
sequence of pseudo-random numbers. The initial seed is 1.
calloc allocates space for an array of objects.
calloc returns a pointer to space for an array of
nobj objects, each of size size, or
NULL if the request
cannot be satisfied. The space is initialised to zero
bytes.
malloc allocates space for an object.
malloc returns a pointer to space for an object of
size size, or NULL if the request cannot be
satisfied. The space is uninitialised.
realloc changes the size of the object pointed to
by p to size. The contents will
be unchanged up to the minimum of the old and new sizes.
If the new size is larger, the new space is uninitialised.
realloc returns a pointer to the new space or NULL if the request
cannot be satisfied, in which case *p is
unchanged.
free deallocates the space pointed to by
p; it does nothing if p is NULL.
p must be a pointer to space previously allocated
by calloc, malloc,
or realloc.
abort causes the program to terminate
abnormally, as if by raise(SIGABORT).
exit causes normal program termination.
atexit functions are called in
reverse order of registration, open files are flushed, open
streams are closed, and control is returned to the
environment. How status is returned to
the environment is implementation-dependent, but zero is
taken as successful termination. The values
EXIT_SUCCESS and EXIT_FAILURE may
also be used.
atexit registers the function fcn to
be called when the program terminates normally.
atexit returns non-zero if the registration cannot
be made.
system passes the string s to the
environment for execution.
s is NULL,
system returns non-zero if there is a command
processor. If s is not NULL, the return
value is implementation-dependent.
getenv returns the environment string associated
with name, or NULL if no string exists. Details are
implementation-dependent.
bsearch searches
base[0]...base[n-1] for an item that
matches *key. The function cmp
must return negative if its first argument (the search key) is
less than its second (a table entry), zero if equal, and
positive if greater. Items in the array base
must be in ascending order.
bsearch returns a pointer to the matching
item, or NULL if none
exists.
qsort sorts into ascending order an array
base[0]...base[n-1] of objects of size
size. The comparison function cmp
must return negative if its first argument (the search key) is
less than its second (a table entry), zero if equal, and
positive if greater.
abs returns the absolute value of its
int argument.
labs returns the absolute value of its
long argument.
div computes the quotient and remainder of
num/denom. The results are stored in the
int members quot and rem
of a structure of type div_t.
ldiv computes the quotient and remainder of
num/denom. The results are stored in the
long members quot and rem
of a structure of type ldiv_t.
s is not a null pointer, mblen
determines the number of bytes contained in the multibyte
character pointed to by s. Except that the
shift state of the mbtowc function is not
affected, it is equivalent to
mbtowc((wchar_t *)0, s, n);
mbstowcs converts a sequence of multibyte
characters that begins in the initial shift state from the
array pointed to by s into a sequence of
corresponding codes and stores not more than n
codes into the array pointed to by pwcs. No
multibyte characters that follow a null character (which is
converted into a code with value zero) will be examined or
converted. Each multibyte character is converted as if by
a call to the mbtowc function, except
that the shift state of the mbtowc
function is not affected.
No more than n elements will be modified in the
array pointed to by pwcs. If copying takes
place between objects that overlap, the behaviour is
undefined.
(size_t)-1. Otherwise, the mbstowcs function returns the number
of array elements modified, not including a terminating
zero code, if any.
s is not a null pointer, mbtowc
determines the number of bytes that are contained in the
multibyte character pointed to by s. It then
determines the code for the value of type wchar_t
that corresponds to that multibyte character. If the
multibyte character is valid and pwc is not a null
pointer, mbtowc stores the code in the object
pointed to by pwc. At most n
bytes of the array pointed to by s will be
examined.
s is a null pointer, mbtowc
returns a nonzero or zero value, if multibyte character
encodings, respectively, do or do not have state-dependent
encodings. If s is not a null pointer,
mbtowc either returns 0 (if s
points to the null character), or returns the number of
bytes that are contained in the converted multibyte
character (if the next n or fewer bytes form
a multibyte character), or returns -1 (if
they do not form a valid multibyte character).
In no case will the value returned be greater than
n or the value of the MB_CUR_MAX
macro.
wcstombs converts a sequence of codes that
correspond to multibyte characters from array pwcs
into a sequence of multibye characters that begins in the
initial shift state and stores these multibyte characters in
s, stopping if a multibyte characters would exceed
the limit of n total bytes or if a null character
is stored. Each code is converted as if by a call to the
wctomb function, except that the shift
state of the wctomb function is not
affected.
wcstombs
function returns (size_t)-1. Otherwise,
the wcstombs function returns the number of
bytes modified, not including a terminating null
character, if any.
wctomb determines the number of bytes needed to
represent the multibyte character corresponding to the code
whose value is wchar (including any change in
shift state). It stores the multibyte character
representation in s (if s in not a
null pointer). At most MB_CUR_MAX characters
are stored. If the value of wchar is zero,
wctomb is left in the initial shift state.
s is a null pointer, wctomb
returns a nonzero or zero value, if multibyte character
encodings, respectively, do or do not have state-dependent
encodings. If s is not a null pointer,
wctomb returns -1 if the value
of wchar does not correspond to a valid
multibyte character, or returns the number of bytes that
are contained in the multibyte character corresponding to
the value of wchar.
In no case will the value returned be greater than the
value of the MB_CUR_MAX macro.
| Table of Contents | Previous | Next |
Last modified: Thu Dec 7 11:17:45 2000