Monday, October 31, 2016

C Library Function – stdlib

The <stdlib.h> header shall define the following function(s).

Numeric conversion Functions:
atof double atof( const char* str );
atoi int atoi( const char *str );
atol long atol( const char *str );
atoll(C99) long long atoll( const char *str );
strtol long strtol( const char *str, char **str_end, int base );
strtoll(C99) long long strtoll( const char *restrict str, char **restrict str_end, int base );
strtoul unsigned long strtoul( const char *str, char **str_end, int base );
strtoull(C99) unsigned long long strtoull( const char *restrict str, char **restrict str_end, int base );
strtof(C99) float strtof( const char *restrict str, char **restrict str_end );
strtod double strtod( const char *str, char **str_end );
strtold(C99) long double strtold( const char *restrict str, char **restrict str_end );

Pseudo-random sequence generation Functions:
rand int rand(void);
srand void srand( unsigned int seed );

Memory management Functions:
malloc void* malloc( size_t size );
calloc void* calloc( size_t nmemb, size_t size );
realloc void *realloc( void *ptr, size_t new_size );
free void free( void* ptr );
aligned_alloc(C11) void *aligned_alloc( size_t alignment, size_t size );

Communication with the environment Functions:
abort _Noreturn void abort(void);
exit _Noreturn void exit(int status);
quick_exit(C11) _Noreturn void quick_exit(int status);
_Exit(C99) _Noreturn void _Exit(int status);
atexit int atexit(void (*func)(void));
at_quick_exit(C11) int at_quick_exit(void (*func)(void));
system int system(const char *string);
getenv char *getenv( const char *name );
getenv_s(C11) errno_t getenv_s( size_t *restrict len, char *restrict value, rsize_t valuesz, const char *restrict name );

Searching and sorting utilities Functions:
bsearch void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
bsearch_s(C11) void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *), void *context);
qsort void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
qsort_s(C11) void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)*), void *context);

Integer arithmetic Functions:
abs int abs(int j);
labs long int labs(long int j);
llabs(C99) long long int llabs(long long int j);
div div_t div(int numer, int denom);
ldiv ldiv_t ldiv(long int numer, long int denom);
lldiv(C99) lldiv_t lldiv(long long int numer, long long int denom);

Multibyte/wide character conversion Functions:
mblen int mblen( const char* s, size_t n );
mbtowc int mbtowc( wchar_t *pwc, const char *s, size_t n );
wctomb int wctomb( char *s, wchar_t wc );
wctomb_s(C11) errno_t wctomb_s(int *restrict status, char *restrict s, rsize_t ssz, wchar_t wc);

Multibyte/wide string conversion Functions:
mbstowcs size_t mbstowcs( wchar_t *dst, const char *src, size_t len);
mbstowcs_s(C11) errno_t mbstowcs_s(size_t *restrict retval, wchar_t *restrict dst, rsize_t dstsz, const char *restrict src, rsize_t len);
wcstombs size_t wcstombs( char *dst, const wchar_t *src, size_t len );
wcstombs_s(C11) errno_t wcstombs_s( size_t *restrict retval, char *restrict dst, rsize_t dstsz, const wchar_t *restrict src, rsize_t len );




Related topics:
Library Functions in C   |   Standard Library in C   |   Header Files in C   |   Functions in C   |   Keywords in C   |   Data Types in C   |   Pointers in C

List of topics: C Programming

No comments:

Post a Comment