I need help with writing these String functions, in C: 1. strcmp(const char *str
ID: 3557987 • Letter: I
Question
I need help with writing these String functions, in C:
1. strcmp(const char *str1, const char *str2)
Compares str1 to str2.
Returns: -1 if str1 is less than str2, 1 if str2 is less than str1, 0 str1 and str2 are equal
2. char *strchr(const char *string, int c);
This function finds the first occurrence of a character in a string. The character c can be the null character (); the ending null character of string is included in the search.
Returns: pointer to the first occurrence of character c in string or a null pointer if no matching character is found.
3. char *strpbrk(const char *str1, const char *str2)
Finds the first character in the string str1 that matches any character specified in str2.
str1 -- This is the C string to be scanned.
str2 -- This is the C string containing the characters to match.
Returns: a pointer to the character in str1 that matches one of the characters in str2, or NULL if no such character is found.
4. char *strcpy(char *dest, const char *src)
Function copies the string pointed to by src to dest.
src: string to be copied
dest: destination of copied string
Returns: A pointer to the destination string dest
Explanation / Answer
2.) Strchr:
3.)strbrk
4.)strcpy