All pastes #977606 Raw Edit

Someone

public c v1 · immutable
·published 2008-04-08 23:04 UTC
rendered paste body
#include <stdio.h>#include <string.h>#pragma warning(disable: 4996 4013)/* Declare functions */void Make(void);char* __FILENAME;char* __COMPARE;int main(int argc, char *argv){    if (argc < 2) {        printf("\n\tUsage: CountLetter filename string\n");        return 0;    }    __FILENAME = argv[1];    __COMPARE = argv[2];    Make();    return 0;}void Make(void){    int count = 0, ch = 0, i = 0, len = strlen(__COMPARE);    FILE *file;        file = fopen(__FILENAME, "r");    if (file == NULL) return;    while (1) {        ch = fgetc(file);        if (ch == EOF) break;        else if (ch == __COMPARE[i]) {            i++;            if (i == len) { count++; i = 0; }        }        else i = 0;    }        fclose(file);    printf("There are %d occurences of %s", count, __COMPARE);}