> Then, if there is a 1 in c1 and c2, find the max (which should be 5.5 in this case) and print with a .2 format.
There are two example of this in your file.
The first time you see it, the max (so far) is 7.2
But the second time you see it, the max has increased to 9.92.
The first step is to get the file reading sorted out.
Code:
char buff[100];
FILE *fp = fopen("file.txt","r");
while ( fgets( buff, sizeof(buff), fp ) != NULL ) {
printf("Read line %s", buff );
}
Then add to that the basics of input conversion.
Code:
char buff[100];
FILE *fp = fopen("file.txt","r");
while ( fgets( buff, sizeof(buff), fp ) != NULL ) {
int c1, c2;
double value;
if ( sscanf( buff, "%d %d : %f", &c1, &c2, &value ) == 3 ) {
printf("c1=%d c2=%d\n", c1, c2 );
} else {
printf("UNKNOWN line %s", buff );
}
}
Can you figure out what to do with c1 and c2 now?
Try JUST ONE of the cases (say the max) and see how you get on.