Function strncmp:
The function strncmp compares only the first n characters in the strings and ignores the rest. The initial two arguments are strings to compare, and third argument is the number of characters to compare the value of n.
>> strncmp(word1,word3,3)
ans =
1
>> strncmp(word1,word3,4)
ans =
0