c++中,stdlib.h的功能

来源:百度知道 编辑:UC知道 时间:2024/05/28 09:44:07
主要是 什么时候使用?

stdlib.h里面定义了五种类型、一些宏和通用工具函数。

类型例如size_t、wchar_t、div_t、ldiv_t和lldiv_t;

宏例如EXIT_FAILURE、EXIT_SUCCESS、RAND_MAX和MB_CUR_MAX等等;

常用的函数如malloc()、calloc()、realloc()、free()、system()、atoi()、atol()、rand()、srand()、exit()等等。

首先,stdlib.h的解释
*Purpose:
* This include file contains the function declarations for commonly
* used library functions which either don't fit somewhere else, or,
* cannot be declared in the normal place for other reasons.

意思是一些常用的函数,但是又不知道把它们放到哪里合适,因此就都放到了stdlib.h这个头文件中。stdlib.h可以提供一些函数与符号常量,具体如下:根据ISO标准,stdlib.h提供以下类型:
size_t, wchar_t, div_t, ldiv_t, lldiv_t
常量
NULL, EXIT_FAILURE, EXIT_SUCESS, RAND_MAX, MB_CUR_MAX
函数
atof, atoi, atol, strtod, strtof, strtols, strtol, strtoll, strtoul, strtoull, rand, srand, callc, free, maloc, realloc, abort, atexit, exit, getenv, system, bsearch, qsort, abs, div, labs, ldiv, llabs, tlldiv, mblen, mbtowc, wctomb, mbstowcs, wcstombs包含函数:
1函