Common Library functions in C language and their functions and header files

Source: Internet
Author: User
Tags acos asin integer division mathematical functions natural logarithm strtok

Character Processing functions
This category function is used to process a single character, including the character category test and case-insensitive conversion of characters.

Header file ctype. h

Function list <>
Function category function usage
Character test whether letters and numbers are isalnum
Isalpha or not
Whether to control the iscntrl character
Isdigit
Whether to display characters (except spaces) isgraph
Whether to display characters (including spaces) isprint
Ispunct, a printable character that is neither a space nor a letter or number
Space or not isspace
Whether to use uppercase letters: isupper
Whether the hexadecimal number (0-9, A-F) character isxdigit
The case-sensitive conversion function converts uppercase letters to toupper.
Convert to lower case tolower

Regionalization
Functions of this category are used to handle different languages in different countries.

Header file local. h

Function list
Function category function usage
Setlocale
The format of the Number Format Convention to query the country's currency, date, time format conversion localeconv

Mathematical functions
This category provides various mathematical computing functions. It must be noted that the data format in ansi c does not conform to the ieee754 standard, while some C language compilers follow the ieee754 standard (such as frinklin C51)

Header file math. h

Function list
Function category function usage
Error Condition processing definition field error (the input parameter value of the function is not within the specified range)
Value Range Error (the return value of the function is not within the specified range)
Trigonometric inverse cosine ACOs
Asin
Switch atan
Arc tangent 2 atan2
Cosine cos
Sine sin
Tangent Tan
Hyperbolic function hyperbolic cosine cosh
Hyperbolic Sinh
Hyperbolic tangent tanh
Exponential and logarithm Exponential Function exp
Exponential decomposition function frexp
Product exponent function fdexp
Natural logarithm log
Base-10 logarithm log10
Floating Point decomposition function MODF
Power Function pow
Square Root function SQRT
Integer truncation. the lower limit of the absolute value and the remainder function is close to the integer Ceil.
Absolute Value FABS
The upper limit is close to the integer floor.
Evaluate the remainder fmod

This category function is used to directly jump code between different base functions. Header file setjmp. h Io. h

Function list
Function category function usage
Save the call environment setjmp
Restore the call environment longjmp

Signal Processing
This classification function is used to handle exceptions during program execution.

Header file signal. h

Function list
Function category function usage
Signal processing function signal
Send signal raise

Variable Parameter Processing
This class of functions is used to implement variable number of parameters such as printf and scanf.

Header file stdarg. h

Function list
Function category function usage
Variable Parameter access macro variable parameter start macro va_start
Variable Parameter end macro va_end
Variable Parameter access macro access next variable parameter macro va_arg

Input and Output Functions
This category is used to process various input and output devices, including files and the console. Various functions are implemented in a "stream" manner.

Header file stdio. h

Function list
Function category function usage
File Operations
Delete file remove
Rename
Generate temporary file name tmpfile
Get the temporary file path tmpnam
File Access close file fclose
Refresh the buffer fflush
Open File fopen
Connect existing stream pointers and new files to freopen
Setbuf
Setvbuf
Format the input and output functions and output the fprintf
Format input fscanf
Format output (console) printf
Format input (console) scanf
Format output to the buffer sprintf
Input sscanf from the buffer in the format
Format and output vfprintf
Format and output vprintf
Format and output vsprintf
Character Input and Output Function input a character fgetc
String input fgets
Character output fputc
String output fputs
Character Input (console) GETC
Character Input (console) getchar
String input (console) gets
Character output (console) putc
Character output (console) putchar
String output (console) puts
Character output to the stream header ungetc
Direct input/output direct stream read operation fread
Direct stream write operation fwrite
The file location function obtains the file location fgetpos.
File Location movement fseek
File Location settings fsetpos
Obtain the file location ftell.
File Location reset zero-bit remind
Clear clearerr
File end judgment feof
File error detection ferror
Returns the error message string perror.

Utility Functions
This category provides some functions that cannot be classified by the above, but are required for programming.

Header file stdlib. h

Function list
Function category function usage
String Conversion Function String Conversion to integer atoi
Convert string to long integer atol
String Conversion to floating point strtodd
String to a long integer strtol
String to unsigned long integer strtoul
Pseudo-random sequence generation function generates random numbers Rand
Set the starting value srand of the random function.
Storage Management Function allocation memory calloc
Free Storage
Memory Allocation malloc
Realloc
Environment communication abort program abort
Exit program execution and clear the environment variable atexit
Exit the program and execute exit
Getenv
The program hangs and temporarily runs another Program System
Binary Search by search and sorting tools (data must be sorted) bsearch
Quick sorting qsort
Evaluate the absolute value of an integer operation function ABS
Div
Obtain the Division operator base and remainder.
Finding the absolute value of a long integer
Calculate the quotient and remainder of the long integer division ldiv
The multi-byte character function obtains the number of bytes of Multi-byte characters mblen.
Obtain the number of bytes of Multi-byte characters mbtowc.
Multi-byte conversion wctomb
Multi-byte character string operation converts a multi-byte string to an integer array mbstowcs
Convert a multi-byte string to a character array mcstowbs

String processing
This function is used to merge and compare strings.

Header file string. h

Function list
Function category function usage
Copy string blocks (the destination and source storage areas cannot overlap) memcpy
Block copy (the destination and source storage areas can overlap) memmove
Strcpy
Copy strncpy by length string
String connection function string connection strcat
Concatenate string strncat by length
Comparison of string comparison function blocks with memcmp
String comparison strcmp
String comparison (for non-English characters) strcoll
Comparison of strncmp strings by length
String Conversion strxfrm
Character and string search character search memchr
Character search strchr
String SEARCH strcspns
String SEARCH strpbrk
String SEARCH strspns
String SEARCH strstr
String decomposition strtok
Miscellaneous function string settings memset
Error string ing strerror
Evaluate the string length strlen

Date and Time Functions
This category provides time and date processing functions.

Header file time. h

Function list
Function category function usage
Time Operation Function to get the processor time clock
Returns the time difference difftime.
Set mktime
Get time
The time conversion function obtains the time asctime in ASCII code.
Returns the time ctime represented by a string.
Get the time in the specified format strftime

Future development direction of function libraries
This section describes how different types of function libraries will develop in the future.

Sequence Number Library category header file details
1. Error Handling errno. h
Ctype. h
3. Merge local. h
4 mathematical functions math. h
5 signal processing signal. h
6 Input and Output stdio. h
7 utility program stdlib. h
8 string processing string. h

Share: 

Character Processing functions
This category function is used to process a single character, including the character category test and case-insensitive conversion of characters.

Header file ctype. h

Function list <>
Function category function usage
Character test whether letters and numbers are isalnum
Isalpha or not
Whether to control the iscntrl character
Isdigit
Whether to display characters (except spaces) isgraph
Whether to display characters (including spaces) isprint
Ispunct, a printable character that is neither a space nor a letter or number
Space or not isspace
Whether to use uppercase letters: isupper
Whether the hexadecimal number (0-9, A-F) character isxdigit
The case-sensitive conversion function converts uppercase letters to toupper.
Convert to lower case tolower

Regionalization
Functions of this category are used to handle different languages in different countries.

Header file local. h

Function list
Function category function usage
Setlocale
The format of the Number Format Convention to query the country's currency, date, time format conversion localeconv

Mathematical functions
This category provides various mathematical computing functions. It must be noted that the data format in ansi c does not conform to the ieee754 standard, while some C language compilers follow the ieee754 standard (such as frinklin C51)

Header file math. h

Function list
Function category function usage
Error Condition processing definition field error (the input parameter value of the function is not within the specified range)
Value Range Error (the return value of the function is not within the specified range)
Trigonometric inverse cosine ACOs
Asin
Switch atan
Arc tangent 2 atan2
Cosine cos
Sine sin
Tangent Tan
Hyperbolic function hyperbolic cosine cosh
Hyperbolic Sinh
Hyperbolic tangent tanh
Exponential and logarithm Exponential Function exp
Exponential decomposition function frexp
Product exponent function fdexp
Natural logarithm log
Base-10 logarithm log10
Floating Point decomposition function MODF
Power Function pow
Square Root function SQRT
Integer truncation. the lower limit of the absolute value and the remainder function is close to the integer Ceil.
Absolute Value FABS
The upper limit is close to the integer floor.
Evaluate the remainder fmod

This category function is used to directly jump code between different base functions. Header file setjmp. h Io. h

Function list
Function category function usage
Save the call environment setjmp
Restore the call environment longjmp

Signal Processing
This classification function is used to handle exceptions during program execution.

Header file signal. h

Function list
Function category function usage
Signal processing function signal
Send signal raise

Variable Parameter Processing
This class of functions is used to implement variable number of parameters such as printf and scanf.

Header file stdarg. h

Function list
Function category function usage
Variable Parameter access macro variable parameter start macro va_start
Variable Parameter end macro va_end
Variable Parameter access macro access next variable parameter macro va_arg

Input and Output Functions
This category is used to process various input and output devices, including files and the console. Various functions are implemented in a "stream" manner.

Header file stdio. h

Function list
Function category function usage
File Operations
Delete file remove
Rename
Generate temporary file name tmpfile
Get the temporary file path tmpnam
File Access close file fclose
Refresh the buffer fflush
Open File fopen
Connect existing stream pointers and new files to freopen
Setbuf
Setvbuf
Format the input and output functions and output the fprintf
Format input fscanf
Format output (console) printf
Format input (console) scanf
Format output to the buffer sprintf
Input sscanf from the buffer in the format
Format and output vfprintf
Format and output vprintf
Format and output vsprintf
Character Input and Output Function input a character fgetc
String input fgets
Character output fputc
String output fputs
Character Input (console) GETC
Character Input (console) getchar
String input (console) gets
Character output (console) putc
Character output (console) putchar
String output (console) puts
Character output to the stream header ungetc
Direct input/output direct stream read operation fread
Direct stream write operation fwrite
The file location function obtains the file location fgetpos.
File Location movement fseek
File Location settings fsetpos
Obtain the file location ftell.
File Location reset zero-bit remind
Clear clearerr
File end judgment feof
File error detection ferror
Returns the error message string perror.

Utility Functions
This category provides some functions that cannot be classified by the above, but are required for programming.

Header file stdlib. h

Function list
Function category function usage
String Conversion Function String Conversion to integer atoi
Convert string to long integer atol
String Conversion to floating point strtodd
String to a long integer strtol
String to unsigned long integer strtoul
Pseudo-random sequence generation function generates random numbers Rand
Set the starting value srand of the random function.
Storage Management Function allocation memory calloc
Free Storage
Memory Allocation malloc
Realloc
Environment communication abort program abort
Exit program execution and clear the environment variable atexit
Exit the program and execute exit
Getenv
The program hangs and temporarily runs another Program System
Binary Search by search and sorting tools (data must be sorted) bsearch
Quick sorting qsort
Evaluate the absolute value of an integer operation function ABS
Div
Obtain the Division operator base and remainder.
Finding the absolute value of a long integer
Calculate the quotient and remainder of the long integer division ldiv
The multi-byte character function obtains the number of bytes of Multi-byte characters mblen.
Obtain the number of bytes of Multi-byte characters mbtowc.
Multi-byte conversion wctomb
Multi-byte character string operation converts a multi-byte string to an integer array mbstowcs
Convert a multi-byte string to a character array mcstowbs

String processing
This function is used to merge and compare strings.

Header file string. h

Function list
Function category function usage
Copy string blocks (the destination and source storage areas cannot overlap) memcpy
Block copy (the destination and source storage areas can overlap) memmove
Strcpy
Copy strncpy by length string
String connection function string connection strcat
Concatenate string strncat by length
Comparison of string comparison function blocks with memcmp
String comparison strcmp
String comparison (for non-English characters) strcoll
Comparison of strncmp strings by length
String Conversion strxfrm
Character and string search character search memchr
Character search strchr
String SEARCH strcspns
String SEARCH strpbrk
String SEARCH strspns
String SEARCH strstr
String decomposition strtok
Miscellaneous function string settings memset
Error string ing strerror
Evaluate the string length strlen

Date and Time Functions
This category provides time and date processing functions.

Header file time. h

Function list
Function category function usage
Time Operation Function to get the processor time clock
Returns the time difference difftime.
Set mktime
Get time
The time conversion function obtains the time asctime in ASCII code.
Returns the time ctime represented by a string.
Get the time in the specified format strftime

Future development direction of function libraries
This section describes how different types of function libraries will develop in the future.

Sequence Number Library category header file details
1. Error Handling errno. h
Ctype. h
3. Merge local. h
4 mathematical functions math. h
5 signal processing signal. h
6 Input and Output stdio. h
7 utility program stdlib. h
8 string processing string. h

Related Article

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.