5 unsigned int i
, j
, k
, l
;
6 unsigned int matches
= 0;
9 /* Text size 7, pattern size 3, so the last element would be 7 - 3 + 1 = 5 */
10 for (y
= 0; y
< n
- m
+ 1; y
++) {
12 for (x
= 0; x
< n
- m
+ 1; x
++) {
14 k
= y
; /* reset text's vertical k (not to 0 but to the number of vertical loops) */
16 for (l
= 0; l
< m
; l
++) {
18 i
= x
; /* reset text's horizontal i (not to 0 but to the number of horizontal loops) */
20 for (j
= 0; j
< m
; j
++) {
22 if ( pattern
[l
][j
] != text
[k
][i
] )
25 i
++; /*increase horizontal drift*/
28 k
++; /*increase vertical drift*/
31 /* If we reached here we should have a match */