目前只能处理短序列,若要处理长序列,可按照https://www.cnblogs.com/mmtinfo/p/13036039.html的读取方法。
1 #include
2 #include
3 #include
4 #define RLEN 1024
5
6 static void getfq(char *fq, char *ofq);
7
8 int main(int argc, char *argv[]){
9
10 if(argc!=3){
11 printf("infomation:\n");
12 fprintf(stderr,"\tusage: %s
13 exit(-1);
14 }
15 getfq(argv[1],argv[2]);
16 exit(0);
17 }
18
19 static void getfq(char *fq, char* ofq){
20
21 FILE *fp1=fopen(fq,"r");
22 FILE *fp2=fopen(ofq,"w");
23
24 char fline[RLEN];
25 char read[4][RLEN];
26 char *r=NULL;
27
28 while(fp1 != NULL && fp2 != NULL){
29
30 for(int i=0; i<4; i++){
31 r=fgets(fline,RLEN,fp1);
32 if(r != NULL){
33 strcpy(read[i],fline);
34 }
35 else{ // EOF
36 goto LoopOut;
37 }
38 }
39
40 for(int i=0; i<4; i++){
41 switch(i)
42 {
43 case 0:
44 memcpy(read[i],">",1);
45 fprintf(fp2,"%s",read[i]);
46 break;
47 case 1:
48 fprintf(fp2,"%s",read[i]);
49 break;
50 case 2:
51 continue;
52 break;
53 case 3:
54 continue;
55 break;
56 default:
57 break;
58 }
59 }
60 }
61 LoopOut:
62 free(r);
63 r=NULL;
64 free(fp1);
65 free(fp2);
66
67 return;
68 }
手机扫一扫
移动阅读更方便
你可能感兴趣的文章