C-Language Character and string processing functions

Source: Internet
Author: User
Tags strtok uppercase character

 

# Include <ctype. h>

Int isalnum (int c) test whether C is a letter or number

Int isalpha (int c) test whether C is a letter

Int iscsym (int c) test whether C is a letter, underline, or number

Int iscsymf (int c) test whether C is a letter or underscore

Int isdigit (int c) test whether C is a decimal number

Int isxdigit (int c) test whether C is a hexadecimal number

Int islower (int c) test whether C is a lowercase letter

Int isupper (int c) test whether C is a capital letter

Int ispunct (int c) test whether C is a punctuation mark

Int isspace (int c) test whether C is blank

Int isgraph (int c) test whether C is printable

Int isascii (int c) determines whether C is an ASCII character (0-127)

Int toasscii (int c) converts character C to ASCII

Int tolower (int c) converts character C to lowercase characters

Int toupper (int c) converts character C to uppercase character

# Include <stdlib. h>

Double atof (const char * nptr) converts a string to a double-precision floating point number.

Int atoi (const char * nptr) converts a string to an integer.

Long atol (const char * nptr) converts a string into a growth integer.

Double strtodd (const char * nptr, char ** endptr) converts a string to a double-precision floating-point number.

Loing int strtol (const char * nptr, char ** endptr, int base) converts a string into a growth integer.

Unsigned long int strtoul (const char * nptr, char ** endptr, int base) converts a string to an unsigned long integer.

Char * gcvt (double number, sixe_t ndigits, char * buf) converts a floating point integer to a string, rounded

# Include <string. h>

Char * strcpy (char * s1, const char * s2) Copy string s2 to array s1

Char * ctrncpy (char * s1, const char * s2, size_t n) Copy n Bytes starting with string s2 to string array s1

Char * strcat (char * s1, const char * s2) after appending string s2 to string s1

Char * strncat (char * s1, const char * s2, size_t n) after appending n Bytes starting with string s2 to the string in string s1

Int strcmp (const char * s1, const char * s2) compares string s1 with string s2

Int strncmp (const char * s1, const char * s2, size_t n) compares the first n characters of string s1 with string s2

Char * strchr (const char * s, int c) searches for the position where the characters in the C table appear for the first time in string s. A pointer to this position is returned. Otherwise, NULL is returned.

Char * strrchr (const char * s, int c) returns the position pointer of the character C represents for the last occurrence in s. Otherwise, NULL is returned.

Calculate the size_t strcspn (const char * s1, const char * s2) and return the length of the starting segment of string s1 that does not contain any character in string s2, that is, to check whether the string s1 contains any s2 character. If this character is met, the length of the character from the start to the character is returned.

Calculate and return the length of the Start segment of string s1 that contains only the characters in string s2, that is, when no s2 character is encountered in s1, the length of the string from the start to the character is returned.

Char * strpbrk (const char * s1, const char * s2) searches for the position where any character in string s2 appears for the first time in string s1

Char * strstr (const char * s1, const char * s2) returns the position pointer of string s2 for the first time in string s1. Otherwise, NULL is returned.

The repeated call to the strtok () function of char * strtok (char * s1, const char * s2) Splits string s1 into several marks, these tokens are separated by characters contained in string s2. The first call containing s1 is used as the first parameter. Subsequent calls that continue to divide the same string include NULL as the first parameter, each call will return a pointer to the current mark. If no more marks are provided when a function is called, NULL is returned.

# String memory functions

Void * memcpy (void * s1, const void * s2, size_t n) Copies n characters in the memory block pointed by s2 to the memory block pointed by s1, and returns the pointer of the result object;

Void * memmove (void * s1, const void * s2, size_t n) Copies n characters in the memory block to the temporary space in the memory, returns the pointer of the result to the image in the memory block directed to from the temporary space to s1.

Void memcmp (const void * s1, const void * s2, size_t n) is used to compare the size of the First n characters in the memory block to which s1 and s2 point. The comparison result is returned.

Void * memchr (const void * s, int c, size_t n) finds the place where c appears 1st times in the first n characters of the memory block pointed by s. If c is found, the pointer of c in s1 is returned. Otherwise, null is returned.

Void * memset (void * s, int c, size_t n) Copies c to the first n characters of the memory block pointed to by s, and returns the generated pointer

 

# Other string functions

Char * strerror (int errornum) maps errornum to a plain text string in a system-related manner, and returns a pointer to the string.

Size_t strlen (const char * s) determines the length of string s, returns the number of characters before the string Terminator

 

This article is from the lopnxrp blog

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.