/* primer76.c - poredjenje niski - gruba sila * * pat - obrazac koji se trazi u niski text * mark - vraca pocetak podniske u text koja poredi pat * ili NULL */ #include #include #define EOS '\0' // simbol kraja niske #define MAXP 10 // max. duzxina obrasca #define MAXT 1000 // max. duzxina teksta char *gruba_sila( char *, char * ); main(int argc, char *argv[]) { char pat[MAXP]; char text[MAXT]; char *mark; strcpy(pat, argv[1]); strcpy(text, argv[2]); mark = gruba_sila( pat, text ); printf("%s\n", mark ); } char *gruba_sila( char *pat, char *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 ); }