I have a file abc.txt
with 8000 lines.The file structure would be:
121220122563841210000000 999.999 999.999 999.999
121220122563841210000000 999.999 999.999 999.999
121220122563841210000000 999.999 999.999 999.999
121220122563841210000000 999.999 999.999 999.999
121220122563841210000000 999.999 999.999 999.999
121220122563841210000000 0.2563 0.25698 2.3658
121220122563841210000000 999.999 999.999 999.999
121220122563841210000000 999.999 999.999 999.999
121220122563841210000000 2.365 2.365894 0.15463
121220122563841210000000 999.999 999.999 999.999
121220122563841210000000 999.999 999.999 999.999
121220122563841220000000 4.2563 6.25698 25.3658
The sequence goes on.
I needed to write a program to read the line which do not contain 999.999.Here's how I went.I made a comparison with the values that I read,but it's giving the complete file as output.What is the correct way to do it?
#include <stdio.h>
int main()
{
FILE *fp,&fp2;
char aa[50];
float a,b,c;
fp=fopen("abc.txt","r");
fp2=fopen("aa.txt","w");
while(!feof(fp))
{
fscanf(fp,"%s %f %f %f",&aa,&a,&b,&c);
if((a!=999.999)&&(b!=999.999)&&(c!=999.999))
fprintf(fp2,"%s %f %f %f",&aa,&a,&b,&c);
}
fclose(fp);
fclose(fp1);
}
When I try to use
if((a=999.999)&&(b=999.999)&&(c=999.999))
it's giving only lines that contains 999.999
but I want the lines which do not contain 999.999.
.Bear with me I am new to C.