Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Stdlib. H in C

Explore Stdlib. H in C with clear explanations, practical examples, and useful tips.

Table of Contents

This guide covers stdlib. h in c with practical context and easy-to-follow details. Use it to understand the subject and apply the information confidently.

Stdlib. H in C

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

FAQ

What should I check before following these steps?

Confirm device and software compatibility, save important data, and make sure you have the required permissions, files, and account access.

Why might the process not work?

Common causes include outdated software, missing permissions, incompatible hardware, an unstable connection, or completing a step in the wrong order.

Can I undo the changes if necessary?

That depends on the tool or setting. Use built-in restore options when available, keep a backup, and record the original configuration first.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.