Table of Contents
This guide covers string. h in c with practical context and easy-to-follow details. Use it to understand the subject and apply the information confidently.
String. H in C
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
FAQ
What should I check before following these steps?
Confirm device and software compatibility, save important data, and make sure you have the required permissions, files, and account access.
Why might the process not work?
Common causes include outdated software, missing permissions, incompatible hardware, an unstable connection, or completing a step in the wrong order.
Can I undo the changes if necessary?
That depends on the tool or setting. Use built-in restore options when available, keep a backup, and record the original configuration first.
Reader Comments 0
Sign in with email or Google to join the discussion.