Is it worth explaining?
for( ; *s1 != '\0' && *s2 != '\0'; s1++, s2++ ) {
The first element in a for loop, before the first ';' makes the initial setup, there is no need.
Thus, the for loop works as long as any of the characters pointed to by s1 and s2 are non-zero. Zero marks the end of a line in c and C ++.
The last part of the for loop is what needs to be done in each loop - in this case, it moves the pointers s1 and s2 to point to the next character on each line.
if( *s1 != *s2 ) { return 0;
If the characters pointed to by s1 and s2 do not match, i.e. we found the first different character in two lines, return 0, i.e. false
return 1;
If we get to the end of one of the lines, and we did not find any characters that would be different, return 1 - i.e. true.
Thus, the function returns true if the lines are identical or one line begins with another, and false - lines and different characters.
source share