I have a .txt file which contains 121 COLUMNS and 2 ROWS,now I want to create one new file new.txt which will contain only the class no(A,B,C) which is larger than the value 6 in ROW 2.How to create it?I have tried the following code.
my c.txt file look like following :
A B C D E ..... AAA
12 20 4 7 5 ..... 11
my c.txt file look like following :
A B C D E ..... AAA
12 20 4 7 5 ..... 11
Code:
#include<stdio.h>
#include "conio.h"
#include "stdlib.h"
#include "string.h"
int main()
{
FILE *fp,*fq,*dd;
char Garbage[500];
int a1[500];
int i=0;
fp=fopen("c.txt","r");
fq=fopen("c.xt","r");
dd=fopen("out.txt","w+");
if(fp==NULL)
{
printf("\nNot Exists\n");
exit(1);
}
for(i=0;i<=121;i++)
{
fscanf(fp,"%c",Garbage[i]);
}
for(i=0;i<=121;i++)
{
fscanf(fq,"%d",a1[i]);
}
if(a1>20)
{
fprintf(dd,"%c\n",Garbage);
}
fclose(fp);
fclose(fq);
fclose(dd);
return 0;
}