#include<stdio.h>#include<stdlib.h>void main(){ FILE *fp,*out; char ch; long int i,j,l,n; float k,m; i=0; j=0; l=0; m=0; n=0; if((fp=fopen("c:\\abc.fna","rb"))==NULL) { printf("can not open the file!\n"); exit(0); } if((out=fopen("c:\\abc","w+"))==NULL) { printf("can not open the file!\n"); exit(0); } while(!feof(fp)) { ch=fgetc(fp); // printf("%c\n",ch); if (ch=='A') i++; else if (ch=='G') j++; if ((i+j)!=0) { k=((float)i-(float)j)/((float)i+(float)j); //printf("%f\n",k); l++; } } printf("%d,%d,%f\n",l,j,k); fwrite(&l,sizeof(long int),l,out); fwrite(&k,sizeof(float),1,out); fread(&n,sizeof(long int),1,out); fread(&m,sizeof(float),1,out); printf("%d,%f",n,m); fclose(fp); fclose(out);}