stdlib.h in C

stdlib.h in C

The header file named stdlib.h in Standard C Library defines four variable types, a number of macros and various functions to implement common features.

The variables are defined in stdlib.h

The following lists some types of variables defined in stdlib.h:

Description variable size_t

This is an unsigned integer type and the result of the sizeof keyword

wchar_t

This is an integer type whose size is a constant wide char

div_t

This is the structure returned by the div function

ldiv_t

This is the structure returned by the ldiv function

The macros are defined in stdlib.h

The table below lists some macros defined in stdlib.h:

Macro Description NULL

This macro is the value of a null pointer constant

EXIT_FAILURE

This is the value for exit function to return in case of failure

EXIT_SUCCESS

This is the value for exit function to return in case of success

RAND_MAX

This macro is the maximum value returned by the rand function

MB_CUR_MAX

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

Functions are defined in stdlib.h

Here are some functions defined in stdio.h:

STD & Description1

Double atof function (const char * str)

Convert a string pointed to by parameter str to a floating point number (type double)

2

Int atoi function (const char * str)

Convert a string pointed to by parameter str to an integer (type int)

3

Function long int atol (const char * str)

Convert a string pointed to by parameter str to some long int

4

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

Convert a string pointed to by parameter str to a floating point number (type double)

5

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

Convert a string pointed to by parameter str to some long int

6

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

Converts a string pointed to by parameter str to an unsigned number long int

7

Function void * calloc (size_t nitems, size_t size)

Memory allocation is required and returns a pointer to it

8

Void free function (void * ptr

Free the previously allocated memory by a call to calloc, malloc, or realloc

9

Function void * malloc (size_t size)

Memory allocation is required and returns a pointer to it

ten

Void * realloc function (void * ptr, size_t size)

Attempt to recover the memory block pointed to by str that was previously allocated with a call to malloc or calloc

11

Void abort function (void)

Causing an abnormal program end

twelfth

Int atexit function (void (* func) (void))

Make the func function given to be called when the program ends in the usual way

13

Function void exit (int status)

Make the program end normally

14

Char * getenv function (const char * name)

Search for the environment string pointed to by name and return the value associated with that string

15

Function int system (const char * string)

The command specified by the string is passed to the host environment to be executed by the Command Processor

16

Void function * bsearch (const void * key, const void * base, size_t nitems, size_t size, int (* compar) (const void *, const void *))

Make a Binary Search

17

Void qsort function (void * base, size_t nitems, size_t size, int (* compar) (const void *, const void *))

Arrange an array

18

Int abs function (int x)

Returns the absolute value of x

19

Div_t div function (int numer, int denom)

Divide the numerator numer to the demon number

20

Function long int labs (long int x)

Returns the absolute value of x

21

Ldiv_t ldiv function (long int numer, long int denom)

Divide the numerator numer to the demon number

22

Function int rand (void)

Returns a random number in the range of values ​​from 0 to RAND_MAX

23

Function void srand (unsigned int seed)

This function provides seed for the random number generator used by the rand function

24

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

Returns the length of a multi-byte char pointed to by parameter str

25

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

Convert the string of multi-byte char points pointed to by the parameter str to the array pointed to by pwcs

26

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

Convert a multi-byte sequence into a wide char

27

Function size_t wcstombs (char * str, const wchar_t * pwcs, size_t n)

Convert the code stored in the pwcs array into multi-byte char and store them in the string str

28

Int wctomb function (char * str, wchar_t wchar)

Convert its wide char to a multi-byte char representation and store it at the beginning of the character array pointed to by str

According to Tutorialspoint

Previous lesson: Function of perror () in C

Next lesson: Atof () function in C

5 ★ | 1 Vote

May be interested

  • Check out the 'buffalo' Pokémon in Pokémon GoCheck out the 'buffalo' Pokémon in Pokémon Go
    each type of pokemon has hp, cp, ability to attack and endure differently. based on these indicators, players can determine as well as choosing the most powerful pokemon for their offensive tactics.
  • Sitting home can also locate Pokemon around, do you believe it?Sitting home can also locate Pokemon around, do you believe it?
    the tightening of the niantic developers' rules to prevent players from abusing the support tools also brings annoyance, such as those who have no conditions to move much, go away, it is hard to know. get the location of the pokemon around the area they live in
  • 5 undeniable benefits when playing Pokemon Go5 undeniable benefits when playing Pokemon Go
    get to know many new people, breathe fresh air, relieve stress, increase concentration thanks to going out for a walk .... are compelling reasons to force you to try pokemon go now .
  • Want to earn the fastest Pokécoins in Pokémon Go? So don't miss this article!Want to earn the fastest Pokécoins in Pokémon Go?  So don't miss this article!
    pokécoins in pokémon go play the role of buying items in the store. the more coins you earn, the more likely you are to buy more items. to earn pokécoins, players will have to complete certain tasks or buy real money.
  • Pokémon systems when fighting in Pokémon GoPokémon systems when fighting in Pokémon Go
    each pokémon system in pokémon go has different strengths, along with a specific weakness. this type of pokémon will have the power to attack the other pokémon, but can defeat the other pokémon. if you know the characteristics of each type, it will be easier to choose which pokémon to battle.
  • The terms you need to know when playing Pokémon GoThe terms you need to know when playing Pokémon Go
    pokémon go is the most prominent name in recent days. this game of capturing and training virtual animals has created a relatively new way of playing, as players have to constantly move to catch pokémon. during the process of joining pokémon go, you will encounter and use a lot of important terms. so what do they mean?
  • How to play Pokemon GO on Windows computersHow to play Pokemon GO on Windows computers
    recently, pokemon go has become a popular game, attracting thousands of gamers around the world. in previous posts network administrator has guided you on how to play pokemon go on android devices and ios devices. in the article below, network administrator will guide you how to play pokemon go on windows computers using bluestacks emulator software.
  • How to become a good Pokémon Go hunter?How to become a good Pokémon Go hunter?
    with a new way of playing, pokémon go has created a new phenomenon in the game village around the world. players will have to go around and find pokémon for themselves. so how to quickly catch pokémon and in large numbers?
  • Things to know to upgrade Pokémon in Pokémon GoThings to know to upgrade Pokémon in Pokémon Go
    the whirlwind pokémon go has spread its power right on the first day of its release. everyone rushed to the street to find a pokémon for themselves. therefore, in order to become a pokémon hunter, you need to master the basics of participating in pokémon go battlefield.
  • List of medals received in Pokemon GoList of medals received in Pokemon Go
    in addition to getting items when leveling up, gamers who join pokemon go also have the opportunity to receive their proud achievements.