C ++ xxx function library

xiaoxiao2021-03-06  41

A large difference between C and other languages ​​provides a huge library, which can improve your efficiency. First look at : int RAND (): Returns a random integer. Void Srand (int): Reinitialize the random number generator based on the parameter. INT / FLOAT ABS (INT / FLOAT): The absolute value of the number of returns. Min / Max (A, B): Returns smaller / larger in A and B, defined with #define, you don't have to worry about efficiency. INT ATOI (CHAR * S); and returns an integer converted by the S-string. Double ATOF (CHAR * S); returns a floating point number converted by the S-string. Char * GCVT (Double Num, Int Sig, Char * Str); NUM For the swivel floating point number, SIG is a valid numeric number of converted numbers, STR is the starting point of the target string. The function returns a pointer to the STR. For example, if SIG = 5 So 9.876 will be converted to "9.876", - 123.4578 will become "-123.46", 6.7898E5 is "6.7898e 05".

Then the mathematics functions in : sin, cos, tan: This should understand J. ASIN, ACOS, ATAN: Anti-trigonometric function. SINH, COSH, TANH: Double Triangle Function. Log, Log10: Nature and common logarithm. EXP, POW10: The reverse function of the two functions above. Pow (x, y): Returns the Y power of x. SQRT: Open the square root. CEIL: Returns the smallest of the minimum not less than x. FLOOR: Returns the maximum integer that is not more than X. Hypot (x, y): Returns the square of the square plus the square of the x-ray plus.

Then it is to say that there is a common string function, there is a definition in . Char * STRCPY (Char * DEST, CHAR * SRC);, this function enables DEST = SRC and returns new DEST. Use it to implement the conversion between strings and character arrays. Char * STRCAT (CHAR * DEST, CHAR * SRC);, connect the SRC to the DEST and return to the new DEST. CHAR * STRSTR (Char * S1, CHAR * S2);, return to a pointer to the position of the first occurrence of S2 in S1. CHAR * STRCHR (Char * S1, CHAR C);, returns a pointer to the position of the first occurrence of C in S1. Char * strlwr (char * s);, turn all uppercase letters in S to lowercase. CHAR * STRSET (CHAR * S, CHAR C);, replace all characters in S to character c. INT STRLEN (Char * S); and return the length of the string.

Finally, memory functions in : Memcpy (CHAR * DEST, CHAR * SRC, INT N);, copy the memory content of n bytes starting from the SRC to the memory starting from DEST. Note that the location of DEST and SRCs cannot overlap in memory. Memmove (CHAR * DEST, CHAR * SRC, INT N);, you can also achieve copy, DEST, and SRCs in memory can overlap. Of course, it is slower than Memcpy. MEMSET (S, C, N);, the n bytes starting from S are set to c. Can be used to clear arrays and structures.

转载请注明原文地址:https://www.9cbs.com/read-56308.html

New Post(0)