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


Brute force string searching (Pascal version available)


char *search( pat, text ) char *pat, *text; { int m; if( *pat == EOS ) return( text ); m = strlen(pat); for( ; *text != EOS; text++ ) if( strncmp( pat, text, m ) == 0 ) return( text ); return( NULL ); }

C source (711a.srch.c) Pascal source (711a.srch.p)



© Addison-Wesley Publishing Co. Inc.