I'm getting a bunch of pointer errors and pointers are not exactly my strongest point. Most of my errors have to do with passing an argument.
The errors are:
HW5_mkhan44.c: In function ‘main’: HW5_mkhan44.c:31:3: warning: passing argument 1 of ‘search_and_count’ from incompatible pointer type [enabled by default]
HW5_mkhan44.c:11:6: note: expected ‘struct FILE *’ but argument is of type ‘struct FILE **’
HW5_mkhan44.c:31:3: warning: passing argument 2 of ‘search_and_count’ from incompatible pointer type [enabled by default]
HW5_mkhan44.c:11:6: note: expected ‘const char *’ but argument is of type ‘char * (*)[100]’
HW5_mkhan44.c:31:3: warning: passing argument 3 of ‘search_and_count’ from incompatible pointer type [enabled by default]
HW5_mkhan44.c:11:6: note: expected ‘int *’ but argument is of type ‘int **’
HW5_mkhan44.c:31:3: warning: passing argument 4 of ‘search_and_count’ from incompatible pointer type [enabled by default]
HW5_mkhan44.c:11:6: note: expected ‘int *’ but argument is of type ‘int **’
This is the code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int word_search(const char *word, const char *str);
int character_count(const char *curr_str);
void search_and_count(FILE *fpter, const char *c, int *len, int *result);
int main(void)
{
        FILE *fileptr;
        char filename[100];
        char* word[100];
        int *length;
        int *num;
        printf("Please input the text file name: ");
        scanf("%s", filename);
        fileptr = fopen(filename, "r");
        if(fileptr == NULL)
                printf("File does not exist\n");
        else{
                printf("Please enter a word to search: ");
                scanf("%s", word);
                search_and_count(&fileptr, &word, &length, &num);
                if(*num == 0){
                        printf("Word exists in file");
                        printf("There are %d characters in file", *length);
                }
                else
                        printf("Word does not exist in file");
        }
        fclose(fileptr);
        return 0;
}
int word_search(const char *word,const char *str)
{
        int num;
   if(strcmp(word, str) == 0){
                num = 0;
                return(num);
        }
        else{
                num = 1;
                return(num);
        }
}
int character_count(const char *current_str)
{
        int word_length;
        word_length = strlen(current_str);
        return(word_length);
}
void search_and_count(FILE *fpter, const char *c, int *len, int *result)
{
        char line[120];
        while(fgets(line, sizeof(line), fpter)){
                char* t = strtok(line, " ");
                *len = word_search(c, t);
                *result = character_count(t);
        }
}
 
     
     
    