I am new to C and have to write some code that emulates a given function. However, I am having a difficult time understanding what the second for loop in this code is doing, explicitly. The syntax doesn't seem to follow standard for loop syntax of:
for ( init; condition; increment ) {
statement(s);
}
Here is the code I am examining and it's the second for loop that I am not following and I don't see any online version of this
for (i = 0; i <= (n1-n2); i++){
count=0;
for(j = i,k = 0; k < n2; j++,k++){
if (*(s1+j)!=*(s2+k)){
break;
}
else
count++;
if(count==n2)
total++;
}
}
I'm assuming it's two for loops in one, since there are two increments. And I think the inequality is similar to a 'while loop', but I'm not certain. The confusing piece is that there doesn't seem to be a condition for the j loop. I'm not sure if it's a syntax shortcut or if there is a special loop I can not find a resource for online.
k < n2is the condition for the inner loop - there is no requirement that it has to use the variablej