查找了比较多的资源, 发现没有办法把text 文件转成binary文件
仅作为记录,不过这个例子可以去除换行符。#include
#include
#define N 255
int main()
{
char a[N];
FILE *fp1,*fp2;
fp1=fopen("test_seq.fa","r");
fp2=fopen("testSeq.dat","wb");
/* input text file and output ASCII file no line delimiter*/
if (NULL == fp1){
return -1;
}
while(!feof(fp1)){
if(feof(fp1)){
break;
}
fscanf(fp1,"%s", a);
//fwrite(a, strlen(a),1,fp2);
fwrite(&a, sizeof(char), strlen(a) ,fp2);
}
fclose(fp1);
fclose(fp2);
return 0;
}
编译后, 程序读入test _ seq. fa
输出是 testSeq. dat
#include
#include
int main(void){
int len=2048;
ch