Heya im having a little trouble getting parts of the project to compile;

fscanf(fi, %f, &Max);

this is continualy displaying the error message
"syntax error before '%' token "
i am compiling on Dev- C
its probably simple but help is much appreciated
thanks

here is the program so far

#include <stdio.h>


int main()
{
float Max, Min, Temp;
int i;
FILE *fi;
FILE *fo;
if ((fi = fopen("indata.txt", "r")) == 0)
        {
        printf("error opening file! \n");
        return 1;
        }

fscanf(fi, %f, &Max);
Min = Max;

for (i = 0; i < 8; i ++)
{
    fscanf(fi, %f, &Temp);
    if (Temp > Max)
    {
             Max = Temp;
    }
    if (Temp < Min)
    {
             Min = Temp;
    }
}
fclose(fi);
if ( (fo=fopen("Result.txt", "w")) == NULL )
{
     printf("ERROR opening file!\n");
     return 1;
}

fprintf(fo,"The minimum value found is %f" , Min);
fprintf(fo,", The maximum = £f" , Max);
fclose(fo);
return 0;
           
}
fscanf(fi, "%f", &Temp);

The float format needs to be made a string with " " marks.

where did you save your txt file? ( just a question i'm trying to do something similar to this).

where did you save your txt file? ( just a question i'm trying to do something similar to this).

Same directory where the .exe lives.

if ( (fo=fopen("Result.txt", "w")) == NULL )

Same directory where the .exe lives.

if ( (fo=fopen("Result.txt", "w")) == NULL )

how did you do that?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.