Programming Practice

Library <string.h> of the C Library Reference Guide specifies a collection of functions for string operations. For each of the following function declarations, write its implementation:

size_t strlen(const char *str);

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

char *strcpy(char *str1, const char *str2);

char *strcat(char *str1, const char *str2);

char *strpbrk(const char *str1, const char *str2);

size_t strcspn(const char *str1, const char *str2); 

char *strstr(const char *str1, const char *str2);

Wirte a header file string_functions.h to declare the above functions of your own version and source code file string_functions.c for their implementation. For each function, write an application program to test your functions.

Execution example of string length:

 

Execution example of string comparison:

 

Execution example of string overflow:

 

Execution example of string copy:

 

Execution example of string concatenation:

 

Execution example of string pointer break:

 

Execution example of string span:

 

Execution example of substring match: