[Home]
[Contents]
[Chapter]
[Previous Algorithm]
[Next Algorithm]


String similarity searching (Pascal version available)


char *search( k, pat, text ) int k; char *pat, *text; { int j, m, count; m = strlen(pat); if( m <= k ) return( text ); for( ; *text != EOS; text++ ) { for( count=j=0; j < m && count <= k; j++ ) if( pat[j] != text[j] ) count++; if( count <= k ) return( text ); } return( NULL ); }

C source (718.srch.c) Pascal source (718.srch.p)



© Addison-Wesley Publishing Co. Inc.