Simple File Read Program...
Hello all, i am pretty new with C coding, i am currently working on a hw assignment and ran into trouble...It seems i cant get it to accuratly compare entered value with data file vales and display that CORRECT result...here is the source code, and the file it reads from.
The file it reads from is just a simple txt file containing this data exactly:
2.3 4.5 2.1 -1.5
32.4 16.5 2.2 65.0
11.1 -2.2 -999
The source code is:
Code:
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
int x,c;
double y,z,a,b,d,k=0,e,f,g,h,i;
FILE *input;
FILE *input2;
input=fopen("F:\\Eng c projects\\sentinal.txt","r");
if(input==NULL)
{
printf("File Error");
}
printf("1=Sentinal.txt\n");
printf("2=Prenum.txt\n");
printf("Select File number:\n");
scanf("%i",&x);
if(x==1)
{
printf("File 1 selected.\n");
printf("Enter threshold value:\n");
scanf("%lf",&y);
for(c=0;z>-990;k++)
{
fscanf(input,"%lf",&z);
if (y>z)
{
c++;
printf("c is %i\n",c);
}
else
{
continue;
}
}
}
printf("The num of values less than thresh is %i\n",c);
printf(" k value %f",k);
system("pause");
return(0);
}