Runtime-Support
Functions
-
Summary
General
Utilities
Header
File:
stdlib
_ h
Function
and
Syntax
Description
int
abs(j)
int
j;
Returns the absolute value
of
j
void
abort
( )
Terminates a program abnormally
void
atexit(fun)
Registers the function
point
to
by
fun.
to
be called
without
void
(*fun)
();
arguments at normal program termination
double
atof(nptr)
Converts
an
ASCII string
to
a
floating-point
value
char
*nptr;
int
atoi(nptr)
char
*nptr;
Converts
an
ASCII string
to
an
integer value
long
int
atol(nptr)
c
ar
*nptr;
Converts
an
ASCII string
to
a long integer
void
*bsearch(key,
base,
nme
lb,
size,
compar)
void
*key,
*base;
Searches through
an
array
of
nmemb objects for a member
size-t
nmemb,
size;
that matches the object
that
key
points
to
int
(*compar)
()
;
void
*calloc(nmemb,
size)
Allocates and clears memory for nmemb objects. each
of
size-t
nmemb,
size size
bytes
div-t
div(numer,
denom)
Divides
numer
by
denom
int
numer,
denom
void
exit(status)
Terminates a program normally
int
status;
void
free(ptr)
Deallocates memory space allocated
by
malloc. calloc. or
void
*ptr;
realloc
long
int
labs(j)
Returns the absolute value
of
j
long
int
j;
Idiv_t
Idiv(numer,
denom)
long
int
numer,
denom
Divides
numer
by
denom
int
Itoa(n,
buffer)
Converts n
to
the equivalent ASCII string
long
n;
char
*buffer;
void
*malloc(size)
Allocates memory for
an
object
of
size
bytes
size-t
size;
void
minit()
Resets all the memory previously allocated
by
malloc, calloc,
or realloc
char
*movmem(src,dest,count)
char
*src,
*dest;
int
count;
Moves
count
bytes from one address
to
another
70Id
qsort(base,
nmemb,
size
compar)
void
*base;
Sorts
an
array
of
nmemb members;
base
points
to
the first
size-t
nmemb,
size;
member
of
the unsorted array and
size
specifies the size
int
(*compar)();
of
each member
int
rand()
Returns a sequence
of
pseudo-random integers in the range
o
to
RAN
D-MAX
void
*realloc(ptr,
size)
Changes the size
of
an
allocated memory space
void
*I?tr-
size-t
sl.ze;
void
srand(seed)
Uses
seed
to
reset the random number generator
so
that
unsigned
int
seed;
a subsequent call
to
rand produces a
new
sequence
of
pseu-
do-random numbers
double
strtod(n~tr,
endptr)
Converts
an
ASCII string
to
a
floating-point
value
char
*nptr,
*
endptr;
long
int
strtol(nptr,
end
P
tr
1
base)
char
*nptr,
**endptr;
Converts
an
ASCII string
to
a long integer
int
base;
unsigned
long
int
strtoul(np
r,
endptr,
base)
char
*nptr,
int
base;
**endptr;
Converts
an
ASCII string
to
an
unsigned long integer
6-11