All pastes #977650 Raw Edit

Someone

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