beautypg.com

Atol, Bsearch, Atol bsearch – Zilog Z8F0130 User Manual

Page 458

background image

Appendix B. C Standard Library

UM013037-1212

434

Zilog Developer Studio II – Z8 Encore!
User Manual

Synopsis

#include

int atoi(char *nptr);

Returns

The converted value.

Example

char str []="50";

int x;

x=atoi(str);

atol

Converts the string pointed to by nptr to

long int

representation. Except for the behav-

ior on error, it is equivalent to

strtol(nptr, (char **)NULL, 10)

.

Synopsis

#include

long int atol(char *nptr);

Returns

The converted value.

Example

char str[]="1234567";

long int x;

x=atol(str);

bsearch

Searches an array of nmemb objects, the initial member of which is pointed to by base, for
a member that matches the object pointed to by key. The size of each object is specified by
size.

The array has been previously sorted in ascending order according to a comparison func-
tion pointed to by

compar

, which is called with two arguments that point to the objects

being compared. The

compar

function returns an integer less than, equal to, or greater

than zero if the first argument is considered to be respectively less than, equal to, or
greater than the second.