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 & Description1

Function 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 .

2

Function int memcmp (const void * str1, const void * str2, size_t n)

Compare the first n bytes of two strings str1 and str2 .

3

Function void * memcpy (void * dest, const void * src, size_t n)

Copy n characters from src to dest

4

Void * memmove function (void * dest, const void * src, size_t n)

Another function to copy n characters from src to dest

5

Function 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 .

6

Char * strcat function (char * dest, const char * src)

Append the string pointed to by src, at the end of the string pointed to by dest

7

Char * 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

8

Char * 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

9

Function int strcmp (const char * str1, const char * str2)

Compare the string pointed to by sr1 with the string pointed to by srt2

ten

Function int strncmp (const char * str1, const char * str2, size_t n)

Compare the first n bytes of str1 and str2.

11

Function int strcoll (const char * str1, const char * str2)

Compare strings str1 and str2. The result depends on setting LC_COLLATE

twelfth

Char * strcpy (char * dest, const char * src)

Copy the string pointed to by src to dest

13

Char * strncpy function (char * dest, const char * src, size_t n)

Copy to n characters from the string pointed to by src to dest

14

Function 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

15

Char * strerror (int errnum)

Search for an internal array for errnum error numbers and return a pointer to a string of error messages

16

Function size_t strlen (const char * str)

Calculate the length of str string (not including the ending null character)

17

Char * 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

18

Char * 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

19

Function 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

20

Char * 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

21

Char * strtok function (char * str, const char * delim)

Divide str strings into a series of tokens (smaller strings) separated by delim separators

22

Function 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

3.5 ★ | 2 Vote

May be interested

  • Check out the 'buffalo' Pokémon in Pokémon GoCheck out the 'buffalo' Pokémon in Pokémon Go
    each type of pokemon has hp, cp, ability to attack and endure differently. based on these indicators, players can determine as well as choosing the most powerful pokemon for their offensive tactics.
  • Sitting home can also locate Pokemon around, do you believe it?Sitting home can also locate Pokemon around, do you believe it?
    the tightening of the niantic developers' rules to prevent players from abusing the support tools also brings annoyance, such as those who have no conditions to move much, go away, it is hard to know. get the location of the pokemon around the area they live in
  • 5 undeniable benefits when playing Pokemon Go5 undeniable benefits when playing Pokemon Go
    get to know many new people, breathe fresh air, relieve stress, increase concentration thanks to going out for a walk .... are compelling reasons to force you to try pokemon go now .
  • Want to earn the fastest Pokécoins in Pokémon Go? So don't miss this article!Want to earn the fastest Pokécoins in Pokémon Go?  So don't miss this article!
    pokécoins in pokémon go play the role of buying items in the store. the more coins you earn, the more likely you are to buy more items. to earn pokécoins, players will have to complete certain tasks or buy real money.
  • Pokémon systems when fighting in Pokémon GoPokémon systems when fighting in Pokémon Go
    each pokémon system in pokémon go has different strengths, along with a specific weakness. this type of pokémon will have the power to attack the other pokémon, but can defeat the other pokémon. if you know the characteristics of each type, it will be easier to choose which pokémon to battle.
  • The terms you need to know when playing Pokémon GoThe terms you need to know when playing Pokémon Go
    pokémon go is the most prominent name in recent days. this game of capturing and training virtual animals has created a relatively new way of playing, as players have to constantly move to catch pokémon. during the process of joining pokémon go, you will encounter and use a lot of important terms. so what do they mean?
  • How to play Pokemon GO on Windows computersHow to play Pokemon GO on Windows computers
    recently, pokemon go has become a popular game, attracting thousands of gamers around the world. in previous posts network administrator has guided you on how to play pokemon go on android devices and ios devices. in the article below, network administrator will guide you how to play pokemon go on windows computers using bluestacks emulator software.
  • How to become a good Pokémon Go hunter?How to become a good Pokémon Go hunter?
    with a new way of playing, pokémon go has created a new phenomenon in the game village around the world. players will have to go around and find pokémon for themselves. so how to quickly catch pokémon and in large numbers?
  • Things to know to upgrade Pokémon in Pokémon GoThings to know to upgrade Pokémon in Pokémon Go
    the whirlwind pokémon go has spread its power right on the first day of its release. everyone rushed to the street to find a pokémon for themselves. therefore, in order to become a pokémon hunter, you need to master the basics of participating in pokémon go battlefield.
  • List of medals received in Pokemon GoList of medals received in Pokemon Go
    in addition to getting items when leveling up, gamers who join pokemon go also have the opportunity to receive their proud achievements.