All pastes #977697 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-04-09 00:31 UTC
rendered paste body
#include <stdio.h>

int test(char *t, char *p)
{ 
    int fp, count = 0, ch = 0, i = 0, len;
    len = strlen(p);
    fp = fopen(t, "r");
    while( (ch = getc(fp)) > -1 ) { printf("%c", ch); 
    if( ch == *(p + i) || ch == *p ) { i = ch==*p?1:(i+1); if(i == len) { ++count; i = 0; }}
    else { i = 0; }}
    printf("%i", count);    
}

int main(int argc, char **argv)
{
    test(argv[1], argv[2]);
}