Common functions in the stdlib. h header file

Source: Internet
Author: User
Atof () is a function that converts a string to a floating point number.
Prototype: Double atof (const char * s)
Function: converts the string pointed to by S to the double type.
S format: symbol number. Number e symbol number
Return Value: the conversion value of the string.
Header file: Math. H, stdlib. h

Atoi () converts a string to an integer.
Prototype: int atoi (const char * s)
Function: converts the string pointed to by S to the int type.
S format: Symbol Number
Return Value: the conversion value of the string. If an error occurs, 0 is returned.
Header file: stdlib. h

Atol () converts a string to an integer.
Prototype: Long atol (const char * s)
Function: converts the string pointed to by S to the long int type.
S format: Symbol Number
Return Value: the conversion value of the string. If an error occurs, 0 is returned.
Header file: stdlib. h
========================================================== ==============
Calloc () Memory Allocation Function
Prototype: void * calloc (size_t nitems, size_t size)
Function: allocate a block of memory in the heap and clear all the content of the memory to 0.
Return Value: returns the pointer to the newly allocated memory. If there is not enough space, null is returned.
Header file: stdlib. H, calloc. h
========================================================== ==============
Free () function for releasing allocated memory
Prototype: void free (void * block)
Function: releases the memory allocated by calling calloc, malloc, and realloc functions.
Header file: stdlib. H, alloc. h
========================================================== ================
Gcvt () converts a double-precision number into a string function.
Prototype: char * gcvt (value, ndigit, Buf)
Where: double value is the number to be converted
Int ndigit is the conversion Length
Char * Buf saves the converted address
Header file: stdlib. h
========================================================== ================
Geninterrupt () executes the interrupt function
Prototype: void geninterrupt (int n)
Call method: geninterrupt (Soft Interrupt number)
Function: generate a 8086 Soft Interrupt
Note: The entry information must be transmitted to the register first (using pseudo variables)
For example, Pseudo Variable = value to be assigned (entry information );
The exit information must be received after the geninterrupt () function is called.
For example, variable name = Pseudo Variable
Pseudo Variable: Turbo C allows the use of pseudo variables to directly access the corresponding 8086 register. There are two types of pseudo variables.
① Unsigned INT: _ ax, _ BX, _ CX, _ dx, _ CS, _ DS, _ SS, _ es, _ sp, _ bp, _ Di, _ Si
② Unsigned char: _ Al, _ Ah, _ BL, _ BH, _ Cl, _ CH, _ DL, _ DH
========================================================== ==============
Getenv () is a function that reads the current value of the environment variable.
Prototype: char * getenv (const char * name)
Usage: S = getenv ("environment variable name ");
Char * s needs to be defined first;
Function: returns a given environmental variable value. The environmental variable name can be in uppercase or lowercase. If the specified variable is not defined in the environment, an empty string is returned.
Header file: stdlib. h
========================================================== ================
ITOA () function that converts an integer to a string
Prototype: char * ITOA (INT value, char * string, int Radix)
Function: Convert the value of value to a null string and store the result in the string. Radix is the base value of the conversion, between 2 and 36. The space allocated to the string must accommodate all returned bytes (up to 17 bytes ).
Return Value: pointer to string
Header file: stdlib. h
========================================================== ============
_ Lrotl () is a function that shifts the number of unsigned long integers to the Left Loop.
Prototype: Unsigned long _ lrotl (unsigned long value, int count)
Function: moves the value to the Left Loop by the count bit.
Return Value: Move the value to the Left Loop after the count bit.
Header file: stdlib. h

_ Lrotr () is a function that shifts the number of unsigned long integers to the Right Loop.
Prototype: Unsigned long _ lrotr (unsigned long value, int count)
Function: round the value to the right to move the Count bit.
Return Value: round the value to the right to move the value after the count bit.
Header file: stdlib. h

Ltoa () function that converts a long integer to a string.
Prototype: char * ltoa (long value, char * string, int Radix)
Function: Convert the value of value to a null string and store the result in the string. Radix is the base value of the conversion, between 2 and 36. The space allocated to the string must accommodate all returned bytes (up to 33 bytes ).
Return Value: pointer to string
Header file: stdlib. h

Malloc () Memory Allocation Function
Prototype: void * malloc (size_t size)
Function: allocate size-byte blocks from the heap. Win32 is also applicable.
Return Value: return the address of the newly allocated memory. If there is not enough memory, null is returned.
Header file: alloc. H, stdlib. h
========================================================== ================================
Putenv (): Put the string into the function in the current environment.
Prototype: int putenv (const char * name)
Example: putenv ("Path = C:/B/TC ");
Function: adds the string name to the environment where the current program is running. When the program ends, the original environment will be restored.
Return Value: 0 (successful);-1 (failed)
Header file: stdlib. h
========================================================== ================================
Realloc () memory Reallocation Function
Prototype: void * realloc (void * block, size_t size)
The block points to the memory obtained by using malloc, calloc, or realloc.
Size is the size of the redistributed bytes.
Returned value: the address of the allocated block. If redistribution is not allowed, null is returned.
Header file: stdlib. h
========================================================== ==================================
_ Rotl () is a function that shifts the number of unsigned integers to the Left Loop.
Prototype: Unsigned _ rotl (unsigned value, int count)
Function: moves the value to the Left Loop by the count bit.
Return Value: Move the value to the Left Loop after the count bit.
Header file: stdlib. h
========================================================== ==================================
_ Rotr () is a function that shifts the number of unsigned integers to the Right Loop.
Prototype: Unsigned _ rotr (unsigned value, int count)
Function: round the value to the right to move the Count bit.
Return Value: round the value to the right to move the value after the count bit.
Header file: stdlib. h

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.