#include int main () { char a[20], b[20]; int lena=0, lenb=0, common=1; scanf("%s %s", a,b); /* determine the lengths of the strings--could have used strlen here */ while ( a[lena]!='\0' ) { lena++; } while ( b[lenb]!='\0' ) { lenb++; } /* work backwards as long as the characters are the same */ while ( a[lena-common] == b[lenb-common] && lena-common>=0 && lenb-common>=0 ) { common++; } printf("Common characters: %i\n", common-1); }