i make this simple C program whose purpose is to count the characters that are in a text file which is given through the second command line argument. The problem i face is that fseek shows not responds with a result to have an infinite loop (while(!feof(fp))) in function "Counter".By replacing the fseek with a fgetc the programm works fine.My my question is what is going wrong with the fseek. Thanks in advance.
#include <stdio.h>
int Counter (FILE * fp);
int main(int argc, char* argv[])
{
int cntr;
FILE * fpc;
fpc = fopen(argv[1],"r");
cntr = Counter(fpc);
fclose(fpc);
printf("%i\n",cntr);
}
int Counter (FILE * fp)
{
int cntr = 0;
while (!feof(fp))
{
cntr++;
fseek(fp,1,1);
}
return cntr;
}