DEC C
Language Reference Manual


Previous Contents Index

9.12 General Utilities (<stdlib.h>)

The <stdlib.h> header file declares four types and several functions of general use, and defines several macros. The functions perform string conversion, random number generation, searching and sorting, memory management, and similar tasks.

Types

size_t

wchar_t

div_t

ldiv_t

Macros

NULL

EXIT_FAILURE/EXIT_SUCCESS

RAND_MAX

MB_CUR_MAX

String Conversion Functions

double atof(const char*nptr);

int atoi(const char*nptr);

long int atol(const char*nptr);

double strtod(const char*nptr, char **endptr);

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

unsigned long int strtoul(const char *nptr, char **endptr, int base);

Pseudo-Random Sequence Generation Functions

int rand(void);

void srand(unsigned intseed);

Memory Management Functions

void*calloc(size_t nmemb, size_t size);

void free(void*ptr);

void*malloc(size_t size);

void*realloc(void *ptr, size_t size);

Communication with the Environment

void abort(void);

int atexit(void (*func)(void));

void exit(intstatus);

char*getenv(const char *name);

int*system(const char *string);

Searching and Sorting Utilities


void *bsearch(const void *key, const void *base,   
  size_t nmemb, size_t size, int (*compar) 
  (const void *, const void *)); 


void qsort(void *base, size_t nmemb, 
size_t size, int (*compar) (const void *, 
const void *)); 

Integer Arithmetic Functions

int abs(intj);

div_t div(int numer, int denom);

long int labs(long intj);

ldiv_t ldiv(long int numer, long int denom);

Multibyte Character Functions

int mblen(const char*s, size_t n);

int mbtowc(wchar_t *pwc, const char *s, size_t n);

int wctomb(char*s, wchar_t wchar);

Multibyte String Functions

size_t mbstowcs(wchar_t *pwcs, const char *s, size_t n);

size_t wcstombs(char *s, const wchar_t *pwcs, size_t n);

9.13 String Processing (<string.h>)

The <string.h> header file declares one type and several functions, and defines one macro useful for manipulating character arrays that other objects treat as character arrays.

There are two kinds of string functions declared. The first, with names beginning with str, manipulate character arrays; the second, with names beginning with mem, manipulate other objects treated as character arrays. Except for memmove, function behavior is undefined if copying takes place between overlapping objects.

Type

size_t

Macro

NULL

Functions

void*memcpy(void *s1, const void *s2, size_t n);

void*memmove(void *s1, const void *s2, size_t n);

void*memchr(const void *s, int c, size_t n);

int memcmp(const void*s1, const void *s2, size_t n);

void*memset(void *s, int c, size_t n);

char*strcpy(char *s1, const char *s2);

char*strncpy(char *s1, const char *s2, size_t n);

char*strcat(char *s1, const char *s2);

char*strncat(char *s1, const char *s2, size_t n);

int strcmp(const char*s1, const char *s2);

int strcoll(const char*s1, const char *s2);

int strncmp(const char*s1, const char *s2, size_t n);

size_t strxfrm(char *s1, const char *s2, size_t n);


Previous Next Contents Index