Stdlib.h là gì, c — #include

      288

The stdlib.h header defines four variable types, several macros, & various functions for performing general functions.

Bạn đang xem: Stdlib.h là gì, c — #include

Bạn đang xem: Stdlib.h là gì

Library Variables

Following are the variable types defined in the header stdlib.h −

Sr.No.Variable & Description
1

size_t

This is the unsigned integral type & is the result of the sizeof keyword.

2

wchar_t

This is an integer type of the size of a wide character constant.

3

div_t

This is the structure returned by the div function.

4

ldiv_t

This is the structure returned by the ldiv function.

Library Macros

Following are the macros defined in the header stdlib.h −

Sr.No.Macro và Description
1

NULL

This macro is the value of a null pointer constant.

2EXIT_FAILURE

This is the value for the exit function to lớn return in case of failure.

3

EXIT_SUCCESS

This is the value for the exit function to lớn return in case of success.

4

RAND_MAX

This macro is the maximum value returned by the rand function.

5

MB_CUR_MAX

This macro is the maximum number of bytes in a multi-byte character set which cannot be larger than MB_LEN_MAX.

Library Functions

Following are the functions defined in the header stlib.h −

Sr.No.Function & Description
1double atof(const char *str)

Converts the string pointed to lớn, by the argument str lớn a floating-point number (type double).

2int atoi(const char *str)

Converts the string pointed to, by the argument str lớn an integer (type int).

3long int atol(const char *str)

Converts the string pointed to, by the argument str to a long integer (type long int).

4double strtod(const char *str, char **endptr)

Converts the string pointed khổng lồ, by the argument str lớn a floating-point number (type double).

5long int strtol(const char *str, char **endptr, int base)

Converts the string pointed lớn, by the argument str lớn a long integer (type long int).

6unsigned long int strtoul(const char *str, char **endptr, int base)

Converts the string pointed lớn, by the argument str to an unsigned long integer (type unsigned long int).

7void *calloc(size_t nitems, size_t size)

Allocates the requested memory và returns a pointer to it.

8void free(void *ptr

Deallocates the memory previously allocated by a hotline to lớn calloc, malloc, or realloc.

Xem thêm: " Yeet Là Gì - Bóc Term: Yeet Là Gì Mà Lúc

9void *malloc(size_t size)
10void *realloc(void *ptr, size_t size)

Attempts lớn rekích thước the memory blochồng pointed to by ptr that was previously allocated with a gọi khổng lồ malloc or calloc.

11void abort(void)

Causes an abnormal program termination.

12int atexit(void (*func)(void))

Causes the specified function func lớn be called when the program terminates normally.

13void exit(int status)

Causes the program khổng lồ terminate normally.

14char *getenv(const char *name)

Searches for the environment string pointed lớn by name and returns the associated value to the string.

15int system(const char *string)

The commvà specified by string is passed to lớn the host environment to lớn be executed by the command processor.

16void *bsearch(const void *key, const void *base, size_t nitems, size_t kích thước, int (*compar)(const void *, const void *))

Performs a binary search.

17void qsort(void *base, size_t nitems, size_t kích thước, int (*compar)(const void *, const void*))

Sorts an array.

18int abs(int x)

Returns the absolute value of x.

19div_t div(int numer, int denom)

Divides numer (numerator) by denom (denominator).

20long int labs(long int x)

Returns the absolute value of x.

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

Divides numer (numerator) by denom (denominator).

22int rand(void)

Returns a pseudo-random number in the range of 0 to lớn RAND_MAX.

23void srand(unsigned int seed)

This function seeds the random number generator used by the function rand.

24int mblen(const char *str, size_t n)

Returns the length of a multibyte character pointed lớn by the argument str.

25size_t mbstowcs(schar_t *pwcs, const char *str, size_t n)

Converts the string of multibyte characters pointed to by the argument str khổng lồ the array pointed lớn by pwcs.

26int mbtowc(whcar_t *pwc, const char *str, size_t n)

Examines the multibyte character pointed to by the argument str.

27size_t wcstombs(char *str, const wchar_t *pwcs, size_t n)
28int wctomb(char *str, wchar_t wchar)Examines the code which corresponds to lớn a multibyte character given by the argument wchar.
Chuyên mục: Hỏi Đáp
*