Summary of common functions of C language (non-original)

Source: Internet
Author: User
Tags natural logarithm square root strcmp uppercase letter

///////////////////////////////////////////////////////////////////////////////////////////
The mathematical library functions are declared in MATH.H, mainly:
ABS (x) to find the absolute value of the integer number x
Cosine of cos (x) x (radians)
Fabs (x) to find the absolute value of the floating-point number X
Ceil (x) to find the smallest integer not less than X
Floor (x) to find the smallest integer not greater than X
Log (x) to find the natural logarithm of x E
LOG10 (x) to find the logarithm of X (base 10)
The POW (x, y) asks X's Y-square
Sin (x) to find the sine of x (radians)
sqrt (x) to find the square root of X
////////////////////////////////////////////////////////


Character processing functions
It is stated in Ctype.h that the main:
int isdigit (int c) to determine if C is a numeric character
int isalpha (int c) to determine if C is a letter
int isalnum (int c) determines whether C is a number or a letter
int islower (int c) to determine if C is a lowercase letter
int isupper (int c) to determine if C is an uppercase letter
int toupper (int c) If c is a lowercase letter, return its uppercase letter
int tolower (int c) If C is an uppercase letter, returns its lowercase letter

////////////////////////////////////////////////////////////////////////////


string and memory manipulation functions are declared in string.h, which are commonly used:

char * STRCHR (char * s, int c), if s contains the character C, returns a pointer to the character that the first occurrence of s, otherwise returns null
char * STRSTR (char * s1, char * s2), if S2 is a substring of S1, returns a pointer to S1 where S2 first appears, otherwise returns null
char * STRLWR (char * s) turns the letters in s to lowercase
char * STRUPR (char * s) turns the letters in S to uppercase
char * strcpy (char * s1, char * s2) copies the contents of the string S2 to S1
char * strncpy (char * s1, char * s2,int N) copies the contents of the string S2 to S1, but copies up to n bytes.
If the number of copied bytes reaches N, then the end of ' s1 ' will not be written to the
char * strcat (char * s1, char * s2) adds a string S2 to the end of S1
The int strcmp (char * s1, char * s2) compares two strings, which are case-sensitive. If the return value is less than 0, the S1 is preceded by S2 in dictionary order;
The return value equals 0, which means that two strings are the same; the return value is greater than 0, then the S1 is in dictionary order after S2.
The int stricmp (char * s1, char * s2) compares two strings, regardless of the casing. Other and strcmp with.
void * memcpy (void * s1, void * s2, int n) copies the n-byte content at the S2 of the memory address to the memory address S1.
void * memset (void * s, int c, int n) Place all n bytes starting with the memory address S as C.
///////////////////////////////////////////////////////////////////////////////


A function such as converting a string to an integer, or converting an integer to a string. They are defined in the Stdlib.h:

int atoi (char *s) converts the contents of the string s into an integer number returned. For example, if the contents of the string s are "1234", then the function return value is 1234.
Double atof (char *s) converts the contents of the string s into floating-point numbers. A to int.////a to Flor
char *itoa (int value, char *string, int radix), and integer value value is written to string as a radix-binary notation. Like what:
Char szvalue[20];
Itoa (32,szvalue,10) makes the content of Szvalue become "32";
Itoa (32,szvalue,16) makes the szvalue content "20"


This article is from the "HPUWL" blog, make sure to keep this source http://hpuwl2012.blog.51cto.com/5347969/955590

Summary of common functions of C language (non-original)

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.