Problem A
C String Functions
Write your own implementations of strlen, strcmp, strcpy, and strcat for null-terminated strings.
Use the template which is attached. Submit only your definitions of the functions, the main function is already provided.
Input
The input functionality is already provided, the following is simply informative.
The input consists of two lines. Each line contains a
sequence of lowercase ASCII letters. Each line will contain at
most
Output
The output functionality is already provided.
Sample Input 1 | Sample Output 1 |
---|---|
hello goodbye |
First string: hello Second string: goodbye Length of first string: 5 Length of second string: 7 Comparison of strings: 1 Return value of strcpy correct Copy of first: hello Return value of strcat correct Copy concatenated with second: hellogoodbye |
Sample Input 2 | Sample Output 2 |
---|---|
racecar racecar |
First string: racecar Second string: racecar Length of first string: 7 Length of second string: 7 Comparison of strings: 0 Return value of strcpy correct Copy of first: racecar Return value of strcat correct Copy concatenated with second: racecarracecar |
Sample Input 3 | Sample Output 3 |
---|---|
similar simulate |
First string: similar Second string: simulate Length of first string: 7 Length of second string: 8 Comparison of strings: -1 Return value of strcpy correct Copy of first: similar Return value of strcat correct Copy concatenated with second: similarsimulate |
Sample Input 4 | Sample Output 4 |
---|---|
similar similarity |
First string: similar Second string: similarity Length of first string: 7 Length of second string: 10 Comparison of strings: -1 Return value of strcpy correct Copy of first: similar Return value of strcat correct Copy concatenated with second: similarsimilarity |