Dev C++ Cstdlib
Includes the C Standard library header <stdlib.h> and adds the associated names to the std
namespace. Including this header ensures that the names declared using external linkage in the C standard library header are declared in the std
namespace.
The atof function in C interprets the contents of a string as a floating point number and return its value as a double. 6 minutes to read +4; In this article. Includes the C Standard library header and adds the associated names to the std namespace. Including this header ensures that the names declared using external linkage in the C standard library header are declared in the std namespace. (stdlib.h) C Standard General Utilities Library This header defines several general purpose functions, including dynamic memory management, random number generation, communication with the environment, integer arithmetics, searching, sorting and converting. This header was originally in the C standard library as. This header provides miscellaneous utilities. Symbols defined here are used by several library components.
Requirements
Header: <cstdlib>
Namespace: std
Namespace and Macros
Exposition only functions
Start and termination functions
Function | Description |
---|---|
_Exit | Terminates program without using destructors or registered functions. |
abort | Terminates program without using destructors. |
atexit | Registers function for program termination. |
exit | Destroys objects with thread and static storage, then returns control. |
at_quick_exit | Registers function without arguments for program termination. |
quick_exit | Registers function with preserved objects for program termination. |
getenv | See C standard library reference. |
system | See C standard library reference. |
_Exit
Remarks
The program is terminated without executing destructors for objects of automatic, thread, or static storage duration and without calling functions passed to atexit()
. The function _Exit
is signal-safe.
abort
Remarks
The program is terminated without executing destructors for objects of automatic, thread, or static storage duration and without calling functions passed to atexit()
. The function abort
is signal-safe.
at_quick_exit
Return Value
Zero if the registration succeeds, non-zero if it fails.
Remarks
The at_quick_exit()
functions register a function func, which is called without arguments when quick_exit
is called. A call to at_quick_exit()
that doesn't happen before all calls to quick_exit
may not succeed. The at_quick_exit()
functions don't introduce a data race. The order of registration may be indeterminate if at_quick_exit
was called from more than one thread. Since at_quick_exit
registrations are distinct from the atexit
registrations, applications may need to call both registration functions using the same argument. MSVC supports the registration of at least 32 functions.
atexit
Remarks
The atexit()
functions register the function pointed to by func to be called without arguments at normal program termination. A call to atexit()
that doesn't happen before a call to exit()
may not succeed. The atexit()
functions don't introduce a data race.
Return Value
Returns zero if the registration succeeds, nonzero if it fails.
exit
Remarks
Kong drum designer vst. First, objects with thread storage duration and associated with the current thread are destroyed.
Next, objects with static storage duration are destroyed and functions registered by calling atexit
are called. Automatic objects aren't destroyed when exit()
is called. If control leaves a registered function called by exit
because the function doesn't provide a handler for a thrown exception, std::terminate()
is called. A function is called once for every time it's registered. Objects with automatic storage duration are all destroyed in a program whose main
function contains no automatic objects and executes the call to exit()
. Control can be transferred directly to such a main
function by throwing an exception that's caught in main
.
Next, all open C streams (as mediated by the function signatures declared in <cstdio>) with unwritten buffered data are flushed, all open C streams are closed, and all files created by calling tmpfile()
are removed.
Finally, control is returned to the host environment. When status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. MSVC returns a value of zero. If status is EXIT_FAILURE, MSVC returns a value of 3. Otherwise, MSVC returns the status parameter value.
getenv
quick_exit
Remarks
Generally, functions registered by calls to at_quick_exit
are called in the reverse order of their registration. This order doesn't apply to functions registered after other registered functions have already been called. No objects are destroyed when quick_exit
is called. If control leaves a registered function called by quick_exit
because the function doesn't provide a handler for a thrown exception, std::terminate()
is called. A function registered via at_quick_exit
is invoked by the thread that calls quick_exit
, which can be a different thread than the one that registered it. That means registered functions shouldn't rely on the identity of objects that have thread storage duration. After calling registered functions, quick_exit
calls _Exit(status)
. The standard file buffers aren't flushed. The function quick_exit
is signal-safe when the functions registered with at_quick_exit
are.
system
Memory allocation functions
Remarks
These functions have the semantics specified in the C standard library. MSVC doesn't support the aligned_alloc
function. C11 specified aligned_alloc()
in a way that's incompatible with the Microsoft implementation of free()
, namely, that free()
must be able to handle highly aligned allocations.
Numeric string conversions
Remarks
Dev C Cstdlib Download
These functions have the semantics specified in the C standard library.
Multibyte / wide string and character conversion functions
Remarks
These functions have the semantics specified in the C standard library.
Algorithm functions
Remarks
These functions have the semantics specified in the C standard library.
Low-quality random number generation functions
Remarks
These functions have the semantics specified in the C standard library.
Dev C++ 5.11
Absolute values
Remarks
These functions have the semantics specified in the C standard library.
Integer division
Remarks
These functions have the semantics specified in the C standard library.
See also
Header Files Reference
C++ Standard Library Overview
Thread Safety in the C++ Standard Library
- The C Standard Library
- C Standard Library Resources
- C Programming Resources
- Selected Reading
The stdlib.h header defines four variable types, several macros, and various functions for performing general functions.
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 and 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 & Description |
---|---|
1 | NULL This macro is the value of a null pointer constant. |
2 | EXIT_FAILURE This is the value for the exit function to return in case of failure. |
3 | EXIT_SUCCESS This is the value for the exit function to 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 |
---|---|
1 | double atof(const char *str) Converts the string pointed to, by the argument str to a floating-point number (type double). |
2 | int atoi(const char *str) Converts the string pointed to, by the argument str to an integer (type int). |
3 | long int atol(const char *str) Converts the string pointed to, by the argument str to a long integer (type long int). |
4 | double strtod(const char *str, char **endptr) Converts the string pointed to, by the argument str to a floating-point number (type double). |
5 | long int strtol(const char *str, char **endptr, int base) Converts the string pointed to, by the argument str to a long integer (type long int). |
6 | unsigned long int strtoul(const char *str, char **endptr, int base) Converts the string pointed to, by the argument str to an unsigned long integer (type unsigned long int). |
7 | void *calloc(size_t nitems, size_t size) Allocates the requested memory and returns a pointer to it. |
8 | void free(void *ptr Deallocates the memory previously allocated by a call to calloc, malloc, or realloc. |
9 | void *malloc(size_t size) Allocates the requested memory and returns a pointer to it. |
10 | void *realloc(void *ptr, size_t size) Attempts to resize the memory block pointed to by ptr that was previously allocated with a call to malloc or calloc. |
11 | void abort(void) Causes an abnormal program termination. |
12 | int atexit(void (*func)(void)) Causes the specified function func to be called when the program terminates normally. |
13 | void exit(int status) Causes the program to terminate normally. |
14 | char *getenv(const char *name) Searches for the environment string pointed to by name and returns the associated value to the string. |
15 | int system(const char *string) The command specified by string is passed to the host environment to be executed by the command processor. |
16 | void *bsearch(const void *key, const void *base, size_t nitems, size_t size, int (*compar)(const void *, const void *)) Performs a binary search. |
17 | void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*)) Sorts an array. |
18 | int abs(int x) Returns the absolute value of x. |
19 | div_t div(int numer, int denom) Divides numer (numerator) by denom (denominator). |
20 | long int labs(long int x) Returns the absolute value of x. |
21 | ldiv_t ldiv(long int numer, long int denom) Divides numer (numerator) by denom (denominator). |
22 | int rand(void) Returns a pseudo-random number in the range of 0 to RAND_MAX. |
23 | void srand(unsigned int seed) This function seeds the random number generator used by the function rand. |
24 | int mblen(const char *str, size_t n) Returns the length of a multibyte character pointed to by the argument str. |
25 | size_t mbstowcs(schar_t *pwcs, const char *str, size_t n) Converts the string of multibyte characters pointed to by the argument str to the array pointed to by pwcs. |
26 | int mbtowc(whcar_t *pwc, const char *str, size_t n) Examines the multibyte character pointed to by the argument str. |
27 | size_t wcstombs(char *str, const wchar_t *pwcs, size_t n) Converts the codes stored in the array pwcs to multibyte characters and stores them in the string str. |
28 | int wctomb(char *str, wchar_t wchar) Examines the code which corresponds to a multibyte character given by the argument wchar. |