I am trying to code a program showing the minimum, maximum and mean values from an external file.
the file here is:
31.6 22.4 25.9
30.2 22.7 25.5
31.2 22.9 26.1
31.3 23.4 26.4
30.7 23.2 26.2
31.3 23.1 26.4
31.6 23.9 26.4
31.6 24.0 26.9
32.7 24.7 27.5
33.8 24.8 27.7
32.4 25.0 27.6
32.1 24.9 27.6
32.7 25.4 27.9
31.9 25.5 27.6
31.9 25.4 27.8
32.1 25.3 27.8
31.7 25.6 27.8
32.6 25.2 27.7
32.2 24.9 27.5
32.2 24.9 27.7
31.7 25.8 27.7
32.3 25.5 27.9
32.1 24.4 27.3
31.5 24.6 27.2
31.8 24.0 27.0
32.0 24.4 27.4
32.4 24.9 27.8
32.1 25.0 27.6
and this is the main code: to access and read the file:
#include <stdio.h>
#include <cstdlib>
void main(void)
{
FILE *feb, *mar;
int month, date, count = 0;
double min, max, mean;
char *pch;
char line[256];
printf("Input Month (2 or 3): ");
scanf("%d", &month);
if(month == 2)
{
feb = fopen("feb.txt", "r");
if(!feb)
{
printf("404: File Not Found!");
}
else
{
printf("Input Date (1 ~ 28): ");
scanf("%d", &date);
}
fclose(feb);
}
system("pause");
return 0;
}
The problem is; I can't figure out a way to make it read a specific line and print the values out separately on the output screen.