![]() |
#2
吹水佬2020-02-14 07:11
|

int main(int argc, char** argv)
{
int i,line,flag,b,c;
double a,d;
char ch,filename[1000]={0},data[1000]={0};
FILE *fp=NULL;
FILE *fpp=NULL;
for(b=000,c=101198; b<260; b++,c++)
{
sprintf(filename,"F:\\uz\\uz\\C3energy00%d.txt",b);
//printf("%s\n",filename);
fp=fopen(filename,"r");
if(fp==NULL)
printf("error\n");
for(i=0,line=0;; i++)
{
ch=fgetc(fp);
if(ch=='\n')
line+=1;
if(ch==EOF)
break;
}
//printf("%d\n",line);
fclose(fp); //关闭文件
//循环,读取多个文件数据并写入新的文件
fp=fopen(filename,"r");
for(flag=0; flag<5;) //skip the first five line
{
ch=fgetc(fp);
if (ch=='\n')
{
flag+=1;
}
}
line=line-5;
sprintf(data,"F:\\uz\\new\\data%d.txt",c);
fpp=fopen(data,"w");
//printf("%s\n",data);
if(fpp==NULL)
printf("the file don't exist.\n");
while (fscanf(fp,"%lf %lf",&a,&d)==2)
{
//fpp=fopen(data,"w");
//printf("%e \n",a);
fprintf(fpp,"%lf \n",d*1000);
}
fclose(fp);
fclose(fpp);
}
return 0;
}
只有本站会员才能查看附件,请 登录
附几组数据
只有本站会员才能查看附件,请 登录