I understand that if you have \'cat\' (string1) and \'dog\' (string2) in strcmp (this is a C question) then the return value of strcmp would be less than 0 (since \'cat\' is lex
If you want to compare just the initial len characters of two strings, use strncmp instead of strcmp:
len
#include size_t len = 3; int res = strncmp("dog", "dog2", len);
res will be 0 in this case.