Ok i got it to work, but not quite correct. It reads every character instead of every floating number. It also doesn't read the last line.
Code:
int columns (int input)
{
FILE* spData;
FILE* spOut;
int cur, closeOut;
int col = 0;
int line = 0;
char word = 'o';
if ((spData = fopen ("lab7a.txt", "r")) == NULL)
{
printf (ERR2);
return 1;
}
if ((spOut = fopen ("output.txt", "a")) == NULL)
{
printf (ERR3);
return 1;
}
while ( (cur = fgetc(spData)) != EOF)
{
if (cur == '\t' || cur == ' ')
{
word = 'o';
}
else if (cur == '\n')
{
word = 'o';
line++;
printf ("line %d has %d column\n", line, col);
col = 0;
}
else
{
if (word = 'i');
{
word = 'o';
col++;
}
}
}
// fprintf (spOut, "line %d has %d column\n", line, col);
closeOut = fclose (spOut);
fclose (spData);
return 0;
}