Lab3/Lab3.c
/*
2. Write a recursive version of strcmp. The signature must be
   int my_strcmp_rec(char *str1, char *str2).
   The function should return 0 if the contents of str1 and str2
   are the same.
   If the contents of str1 and str2 are not the same, and the first
   character that doesn't match is at location i, the function
   should return str1[i]-str2[i].
   Each character corresponds to an integer value. For example,
   'A' corresponds to 65, 'B' corresponds to 66, ..., 'Z' 
   corresponds to 90, 'a' corresponds to 97, 'b' corresponds to
   98, ... 
   https://simple.wikipedia.org/wiki/ASCII#/media/File:ASCII-Table-wide.svg
   Returning the difference between the first pair of unmatched characters
   makes it so that strcmp returns a negative value if str1 comes before
   str2 in a lexicographic order.
*/
2. Write a recursive version of strcmp. The signature must be
int my_strcmp_rec(char *str1, char *str2).
The function should return 0 if the contents of str1 and str2
are the same.
If the contents of str1 and str2 are not the same, and the first
character that doesn't match is at location i, the function
should return str1[i]-str2[i].
Each character corresponds to an integer value.
2 . Write a recursive version of strcmp . The signature must be int my_strcmp_rec ( char * str1 char * str2 ) . The function should return 0 if the contents of str1 and str2 are the same . If the contents of str1 and str2 are not the same and the first character that doesn ' t match is at location i the function should return str1 [ i ] - str2 [ i ] . Each character corresponds to an integer value .
int my_strcmp_rec(char *str1, char *str2) {
    if(*str1 == '\0' && *str2 == '\0') {
        printf("%d\n", 0);
        return 0;
    } else if (*str1 != *str2) {
        printf("%d\n", (int)*str1 - (int)*str2);
        return ((int)*str1 - (int)*str2);
    } else {
        str1++;
        str2++;
        return my_strcmp_rec(str1, str2); 
    }
}
int my_strcmp_rec ( char * str1 , char * str2 ) { if ( * str1 == ' \0 ' && * str2 == ' \0 ' ) { printf ( " \n " , 0 ) ; return 0 ; } else if ( * str1 != * str2 ) { printf ( " \n " , ( int ) * str1 - ( int ) * str2 ) ; return ( ( int ) * str1 - ( int ) * str2 ) ; } else { str1 ++ ; str2 ++ ; return my_strcmp_rec ( str1 , str2 ) ; } }
2.
2 .
//printf("%d\n", (int)*str1); //printf("%d\n", (int)*str2); //make sure to return