Common C string processing functions

Source: Internet
Author: User

1. Function Name: stpcpy
Function: copy one string to another.

Usage: char * stpcpy (char * Destin, char * Source );

2. Function Name: strcat
Function: String concatenation Function

Usage: char * strcat (char * Destin, char * Source );

3. Function Name: strchr
Function: searches for the first matching of a given character in a string.

4. Function Name: strcmp
Function: String comparison
Usage:

Int strcmp (char * str1, char * str2 );

5. Function Name: strncmpi
Function: compares a part of a string with another string regardless of case.

Usage: int strncmpi (char * str1, char * str2, unsigned maxlen );

6. Function Name: strcpy
Function: Copy strings

Usage: char * strcpy (char * str1, char * str2 );

7. Function Name: strcspns
Function: Search for the content segment of the first given character set in the string.

Usage: int strcspn (char * str1, char * str2 );

8. Function Name: strdup
Function: copy the string to the new position.

Usage: char * strdup (char * Str );

9. Function Name: stricmp
Function: Compares two strings in upper and lower case insensitive mode.

Usage: int stricmp (char * str1, char * str2 );

10. Function Name: strerror
Function: returns a pointer to the error message string.

Usage: char * strerror (INT errnum );

11. Function Name: strcmpi
Function: compares a string with another string, regardless of case.

Usage: int strcmpi (char * str1, char * str2 );

12. Function Name: strncmp
Function: String comparison

Usage: int strncmp (char * str1, char * str2, int maxlen );

13. Function Name: strncmpi
Function: compares a part of a string with a part of another string, regardless of case.

Usage: int strncmpi (char * str1, char * str2 );

14. Function Name: strncpy
Function: Copy strings

Usage: char * strncpy (char * Destin, char * Source, int maxlen );

15. Function Name: strnset
Function: Set all characters in a string to a specified character.

Usage: char * strnset (char * STR, char CH, unsigned N );

16. Function Name: strpbrk
Function: searches for characters in a given character set in a string.

Usage: char * strpbrk (char * str1, char * str2 );

17. Function Name: strrchr
Function: Find the last occurrence of a specified character in the string.

Usage: char * strrchr (char * STR, char C );

18. Function Name: strrev
Power: String reversal

Usage: char * strrev (char * Str );

19. Function Name: strspns
Function: finds the first occurrence of a subset of a specified character set in a string.

Usage: int strspn (char * str1, char * str2 );

20. Function Name: strstr
Function: Search for the first appearance of a specified string in the string.

Usage: char * strstr (char * str1, char * str2 );

21. Function Name: strtodd
Function: converts a string to a double value.

Usage: Double strtodd (char * STR, char ** endptr );

22. Function Name: strtok
Function: searches for words separated by the delimiters specified in the second string.

Usage: char * strtok (char * str1, char * str2 );
ProgramExample:

23. Function Name: strtol
Function: converts a string to a long integer.

Usage: Long strtol (char * STR, char ** endptr, int base );

24. Function Name: strupr
Function: converts lowercase letters in a string to uppercase letters.

Usage: char * strupr (char * Str );

25. Function Name: swab
Function: swap byte

Usage: void swab (char * From, char * To, int nbytes );

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.