字符串转换:
double atof ( const char * str );
int atoi ( const char * str );
long int atol ( const char * str );
double strtod ( const char * str, char ** endptr );除转换成double外,将数字后字符用endptr指向
long int strtol ( const char * str, char ** endptr, int base );base指进制
unsigned long int strtoul ( const char * str, char ** endptr, int base );
随机数:
int rand ( void );产生0 - RAND_MAX之间的随机数,max至少为32767
void srand ( unsigned int seed );
内存操作:
void * calloc ( size_t num, size_t size );产生num块size大小的内存
void free ( void * ptr );
void * malloc ( size_t size );
void * realloc ( void * ptr, size_t size );重新产生ptr位置的内存至size大小
运行环境操作:
void abort ( void );产生SIGABRT信号,默认中止程序。The program is terminatedwithout executing destructorsfor objects of automatic or static storage duration, and without calling any atexit function.
int atexit ( void ( * function ) (void) );设置中止时回调函数,可设置多次,最后设置的最新运行。C++最多可设置32个函数
void exit ( int status );
char * getenv ( const char * name );返回地址不能修改,且在下次调用getenv时会被覆盖。
int system ( const char * command );
查找操作:
void * bsearch ( const void * key, const void * base, size_t num, size_t size, int ( * comparator ) ( const void *, const void * ) ); 二分查找
void qsort ( void * base, size_t num, size_t size, int ( * comparator ) ( const void *, const void * ) );
数值操作:
int abs ( int n );
long abs ( long n );
div_t div ( int numerator, int denominator ); divresult.quot, divresult.rem分别为除数和余数
ldiv_t div ( long numerator, long denominator );
long int labs ( long int n );
ldiv_t ldiv ( long int numerator, long int denominator );
宽字符操作:
int mblen ( const char * pmb, size_t max );统计宽字符个数,max为最多检测数组长度
int mbtowc ( wchar_t * pwc, const char * pmb, size_t max );
int wctomb ( char * pmb, wchar_t character );
size_t mbstowcs ( wchar_t * wcstr, const char * mbstr, size_t max );
size_t wcstombs ( char * mbstr, const wchar_t * wcstr, size_t max );