i need to write a program which reads three files containing data... this data is organized in the same manner in all of the files and only differs in its numbers...
i wrote a program to read one file and manipulate its content, but i don't know how to get this program to read the other two files following this one in the exact same way..
could i use a function to get this program to work?
int beachnum, sampnum, s;
double samp,total, avg;
ontariofile = fopen ("ontario.txt", "r");
while (fscanf (ontariofile, "%d", &beachnum) != EOF)
total = 0;
fscanf (ontariofile, "%d", &sampnum);
for (s = 1; s <= sampnum; ++s)
fscanf (ontariofile, "%lf", &samp);
total = total + samp;
avg = total / sampnum;
if (avg > 50)
printf ("%d: open\n", beachnum);
else if (avg < 50)
printf ("%d: closed\n", beachnum);
if (sampnum <3)
printf ("%d: insufficient data\n", beachnum);