I need help with a program. I need to know how to make it so the lines with a -1 will not show up. The code is linked to a file. The file looks like this:
4 112.7
154 115.5
4 116.4
321 -1
72 129.8
321 -1
154 219.0
72 128.8
555 110.8
555 137.6
432 86.7
432 -1
If the score was equal to -1 then it would be null. What would I put in here to make it so this happens.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
FILE *olympicfile;
float x;
int i;
int j;
int s;
float Scores[12][2];
olympicfile = fopen( "speed", "r" );
if (olympicfile == NULL)
{
printf("olympicfile not available\n");
exit(1);
}
for(i = 0; i < 12; i++)
{
for (j = 0; j < 2; j++)
{
fscanf(olympicfile, "%f", &x);
Scores[i][j] = x;
}
}
for(i = 0; i < 12; ++i)
{
for(j = 0; j < 2; ++j)
{
printf("%5.1f ", Scores[i][j], Scores[i][j]);
}
printf("\n");
}
fclose( olympicfile );
}