I am programming in C and I start to do some basic programming like wordcount in files, but unfortunately I get flaw in my program's execution. The gcc compiler displays such a warning:
test.c: In function ‘main’:
test.c:11: warning: passing argument 1 of ‘fopen’ makes pointer from integer without a cast
/usr/include/stdio.h:269: note: expected ‘const char * __restrict__’ but argument is of type ‘char’
Line 11 is the line with the if statement
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#define FAIL -1
#define SUCCESS 1
int main (char *filename) {
FILE *fp;
char c;
int wordcount = 0;
if ((fp = fopen(*filename,"r")) == NULL)
return FAIL;
while (!feof(fp))
{
while(!isalpha(fgetc(fp)))
{
wordcount++;
}
}
printf("wordcount: %d",wordcount);
fclose(fp);
return SUCCESS;
}