In the absence of an IDE, it is necessary to remember the function names, parameters, basic usage, and considerations of some commonly used library functions.
Referring to the Linux_c_hs.chm directory, I have roughly divided the usual functions into several categories:
- 1. Memory and string control and operation
- 2. String conversions
- 3. Character test
- 4. File operation
- 5. Time and date
- 6. Common mathematical functions
- 7. File Content operation
- 8. File Permissions Control
- 9. Process Operations
- 10. Threading Operations
- One. Socket operation
- 12. Signal Processing
- 13. Data structures and algorithms
The following is an inductive collation of the first memory and string control and manipulation .
- A function collation that is deprecated
**function name use substitution scheme*1.intBCMP (Const void(SS,Const void*s2, size_t N); Comparebytesequences memcmp**2.voidBcopy (Const void*SRC,void*dest, size_t N); Copybytesequence memcpy Or memmove**3.voidBzero (void*s, size_t N); Write zero-Valued bytes Memset**4.Char*index (Const Char*s,intc); Locate characterinch stringSTRCHR**5.Char*rindex (Const Char*s,intc); Locate characterinch stringSTRRCHR*
- Memory or string lookup function collation
*Function Name Purpose Note*1.void*MEMCHR (Const void*s,intC, size_t N); Scan memory forA character (Forward)returnA pointer to the matchingbyteor NULLifThe character Doe s not occurinchThe given memory area.**2.void*MEMRCHR (Const void*s,intC, size_t N); Scan memory forA character (backward)returnA pointer to the matchingbyteor NULLifThe character Doe s not occurinchThe given memory area.**3.Char*STRCHR (Const Char*s,intc); Locate characterinch string(Forward)returnA pointer to the matched character or NULLifThe character isNot found.**4.Char*STRRCHR (Const Char*s,intc); Locate characterinch string(backward)returnA pointer to the matched character or NULLifThe character isNot found.**5.Char*STRSTR (Const Char*haystack,Const Char*needle); Locate a substringreturna pointer to the beginning of the substring, or NULLifThe substring isNot found.**6.Char*STRCASESTR (Const Char*haystack,Const Char*needle); Locate a Substring,ignores thereturna pointer to the beginning of the substring, Caseof both arguments. or NULLifThe substring isNot found.*
- Memory and string copy, Comparison function collation
*Function Name Purpose Note**1.void*memcpy (void*dest,Const void*src, size_t N); Copy Memory area the memcpy () function returns a pointer to Dest.**2.Char*strcpy (Char*dest,Const Char*SRC); Copy astring returnA pointer to the destinationstringdest.**3.Char*strncpy (Char*dest,Const Char*SRC, size_t N); Copy astring returnA pointer to the destinationstringdest.**4.void*memmove (void*dest,Const void*src, size_t N); Copy memory area, may overlap returns a pointer to Dest.**5.intmemcmpConst void*S1,Const void*s2, size_t N); Compare memory areas Returns an integer less than, equal to, or greater than zeroifThe first n bytes of s1 isfound**6.intstrcmpConst Char*S1,Const Char*S2); Compare stringsreturnAn integer less than, equal to, or greater than zeroifS1 isFoundfound**7.intstrncmpConst Char*S1,Const Char*S2, size_t N); Compare strings up**8.intSTRCASECMP (Const Char*S1,Const Char*S2); Compare strings Ignoring Case up**9.intSTRNCASECMP (Const Char*S1,Const Char*s2, size_t N); Compare strings Ignoring Case up**Ten.Char*strdup (Const Char*s); Duplicate AstringReturns a pointer to aNew stringwhich isA duplicate of thestringS. Memory forTheNew string isobtained with*
- function collation of memory or string joins, splits, lengths, etc.
*Function Name Purpose Note*1.Char*strcat (Char*dest,Const Char*SRC); CONCATENATE stringsreturnA pointer to the resultingstringdest**2.Char*strncat (Char*dest,Const Char*src, size_t N); up up**3.Char*strtok (Char*STR,Const Char*delim); Extract Tokens fromstrings The first call, str must not be empty and the second call to Str must be empty**4.Char*strtok_r (Char*STR,Const Char*delim,Char**saveptr); reentrant function, thread safety recommended Use this partition function, the specific discussion see http://blog.csdn.net/liuintermilan/article/details/6283705*
Above, is the first item of finishing induction. Next, the second string conversion is summarized.
Summarize and organize the common library functions of C language in Linux----memory and string control and operation