[求助]整理速度谱遇到困难,我的程序是哪出错?
我是一个初学者,再整理速度谱资料时遇到了一些困难(人工在excel里做工作量实在太大),于是采用C来完成!C只是以前学过,现在忘了很多,忙了好一阵子,没效果,很郁闷,所以向高手请教一下!
我的数据格式是:
* LIBRI VI 01 (R1T1-R1T100)=T300V1848,T700V1963,T1100V2081,
T1500V2228,T1900V2393,T2300V2554,T2700V2825,
T3100V3037,T3500V3191,T3900V3272,T4300V3350,
T4700V3441,T5100V3531,T5500V3622,T5900V3718,
T6300V3842,VF5500,
上面的数是横着的,我想让它竖着,就是变成
T300V1848,
T700V1963,
T1100V2081,
T1500V2228,
T1900V2393,
T2300V2554,
T2700V2825,
这样我就可以在excel里整理了!谢谢,这是我编的程序:
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
void convert(char infile[],char outfile[]);
main( )
{
char infile[20],outfile[20];
printf("please input infile name:\n");
gets(infile);
printf("please output outfile name:\n");
gets(outfile);
convert(infile,outfile);
}
void convert(char infile[],char outfile[])
{
char temp[50];
FILE *fin,*fout;
if((fin=fopen(infile,"r"))==NULL)
{
printf("can't open input file\n");
exit(0);
}
if((fout=fopen(outfile,"w"))==NULL)
{
printf("can't open output file\n");
exit(0);
}
while(!feof(fin))
{
fscanf(fin,"%s",temp);
if(strcmp(temp,"HANDVEL")==0)
{ fscanf(fin,"%s",temp);
fscanf(fin,"%s",temp);
fscanf(fin,"%s",temp);
fprintf(fout,"HANDVEL ");
}
else
{ fprintf(fout,"%s ",temp);
fscanf(fin,"%s",temp);
fprintf(fout,"%s\n",temp);
}
}
fclose(fin);
fclose(fout);
}
请指教!