string.h in C
string.h in C
The file header named string.h in C Library defines a variable type, a macro and various functions to manipulate character arrays.
The variables are defined in string.h
The table below lists the types of variables that were predefined in string.h:
size_t : This is an unsigned integer type and is the result of the sizeof keyword
The macros are defined in string.h
The following table lists macros that were predefined in string.h:
NULL : This macro is the value of a null pointer constant
The functions are defined in string.h
Here are some functions defined in string.h:
STAMP & Description1Function void * memchr (const void * str, int c, size_t n)
Look for the first occurrence of the character c (an unsigned char) in the first n bytes of the string pointed to by parameter str .
2Function int memcmp (const void * str1, const void * str2, size_t n)
Compare the first n bytes of two strings str1 and str2 .
3Function void * memcpy (void * dest, const void * src, size_t n)
Copy n characters from src to dest
4Void * memmove function (void * dest, const void * src, size_t n)
Another function to copy n characters from src to dest
5Function void * memset (void * str, int c, size_t n)
Copy the character c (an unsigned char) to the first n characters of the string pointed to by parameter str .
6Char * strcat function (char * dest, const char * src)
Append the string pointed to by src, at the end of the string pointed to by dest
7Char * strncat (char * dest, const char * src, size_t n)
Append the string, pointed to by src, at the end of the string pointed to by dest, with a length of up to n characters
8Char * strchr function (const char * str, int c)
Look for the first occurrence of the character c (an unsigned char) in the string pointed to by parameter str
9Function int strcmp (const char * str1, const char * str2)
Compare the string pointed to by sr1 with the string pointed to by srt2
tenFunction int strncmp (const char * str1, const char * str2, size_t n)
Compare the first n bytes of str1 and str2.
11Function int strcoll (const char * str1, const char * str2)
Compare strings str1 and str2. The result depends on setting LC_COLLATE
twelfthChar * strcpy (char * dest, const char * src)
Copy the string pointed to by src to dest
13Char * strncpy function (char * dest, const char * src, size_t n)
Copy to n characters from the string pointed to by src to dest
14Function size_t strcspn (const char * str1, const char * str2)
Calculate the length of the character segment of string str1 without containing the characters in str2
15Char * strerror (int errnum)
Search for an internal array for errnum error numbers and return a pointer to a string of error messages
16Function size_t strlen (const char * str)
Calculate the length of str string (not including the ending null character)
17Char * strpbrk function (const char * str1, const char * str2)
Find the first character in the str1 string that connects any of the characters specified in str2
18Char * strrchr function (const char * str, int c)
Look for the last occurrence of the character c (an unsigned char) in the string pointed to by parameter str
19Function size_t strspn (const char * str1, const char * str2)
Calculate the length of the first paragraph of the str1 string that contains the characters in str2
20Char * function strstr (const char * haystack, const char * needle)
Look for the last occurrence of the whole string needle (not including the ending null character) that is present in the haystack string
21Char * strtok function (char * str, const char * delim)
Divide str strings into a series of tokens (smaller strings) separated by delim separators
22Function size_t strxfrm (char * dest, const char * src, size_t n)
Convert the first n characters of the src string into the current locale and place them in the dest string
According to Tutorialspoint
Previous lesson: wctomb () function in C
Next lesson: Function memchr () in C
You should read it
- String (String) in PHP
- String (String) in C #
- String (String) in C / C ++
- String object in JavaScript
- Some ways to tie the pole or everyone should know
- String in C
- MID and MIDB functions to cut strings in Excel
- The function takes a string in Excel
- How to split strings in Excel
- The computer now finalizes the string, solving it in a flash
- How to Manipulate Strings in Java
- How to insert characters at the beginning or end of a string in Excel
Maybe you are interested
Transparent solar cells help smartphones charge themselves with sunlight
How to charge phone with battery
6 reasons why phones charge slowly
iOS bug causes iPhone to crash when entering these 4 characters
Laptop automatically stops charging when playing games - Fast processing
How to properly plug in the iPhone charger according to Apple's recommendations