I need to write a function that opens a DAT file and calculates the average number of characters per line. Heres what I have so far...
# include <stdio.h>
int main (void)
{
FILE *fp;
int i;
int counter;
char ch;
fp =fopen("TEST.DAT", "r");
for (i = 1; i < EOF; i++)
{
while ((ch = fgetc(fp)) != EOL)
{
if (ch == ' ')
{
counter = counter;
}
else
{
counter = counter +1;
}
}
}
return(0);
}
Any help would be greatly appreciated.