| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1006 人关注过本帖
标题:[求助]整理速度谱遇到困难,我的程序是哪出错?
只看楼主 加入收藏
hexiaohu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-9-17
收藏
 问题点数:0 回复次数:8 
[求助]整理速度谱遇到困难,我的程序是哪出错?
我是一个初学者,再整理速度谱资料时遇到了一些困难(人工在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);
}
请指教!
搜索更多相关主题的帖子: 速度 困难 
2007-09-17 01:01
郑德志
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-9-10
收藏
得分:0 

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);
这段程序是什么意思??????
2007-09-17 09:48
hexiaohu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-9-17
收藏
得分:0 

我是想让它按规格输出来,请指正!

2007-09-17 10:45
百年不亮
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:789
专家分:0
注 册:2006-4-14
收藏
得分:0 
你的程序有什么问题?你应该描述清楚
2007-09-17 10:50
hexiaohu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-9-17
收藏
得分:0 
就是在运行的时候,到了第十三行老是提示:The function shuld return a value
我不知道该修改哪个地方?
2007-09-17 11:17
百年不亮
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:789
专家分:0
注 册:2006-4-14
收藏
得分:0 
再试试:
[CODE]
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int convert(char infile[],char outfile[]);
int 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);

return 0;
}
int 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(1); // 返回1表示出错退出
}
if((fout=fopen(outfile,"w"))==NULL)
{
printf("can't open output file\n");
exit(1); // 返回1表示出错退出
}
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);

return 0; // 返回0表示正常退出
}[/CODE]
2007-09-17 11:24
hexiaohu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-9-17
收藏
得分:0 
版主果然名不虚传,这样一来好多了
不过我还得调啊,输出来的是这样的
3D 1
( 1)=T
0V2229, T
200V2229,T 400V2333,T
600V2471,T 800V2632,T1000V2801,
T1200V2964,T1400V3109,T1600V3231,T1800V3330,T2000V3411, T2200V3482,T2400V3551,T2600V3623,T2800V3697,T3000V3774,
T3200V3852,T3400V3930,T3600V4009,T3800V4088,T4000V4167, T4200V4246,T4400V4325,T4600V4404,T4800V4479,T5000V4547,
T5200V4609,T5400V4666,T5600V4718,T5800V4766,T6000V4811, T6200V4852,T6400V4891,T6600V4927,T6800V4961,T7000V4993,
T7200V5023,T7400V5051,T7600V5077,T7800V5103,T8000V5126, VF5500,
有什么办法让输出来的数据一行只有一个字符串如:
T200V2229,
T400V2333,
T600V2471,
T800V2632,
T1000V2801,
2007-09-17 12:44
百年不亮
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:789
专家分:0
注 册:2006-4-14
收藏
得分:0 

你检测读到的字符,每读到一个','就插入一个换行'\n'不就行了吗?

2007-09-17 13:09
hexiaohu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-9-17
收藏
得分:0 
版主,我试了
可是我不知道把这句语言插到哪,就麻烦你帮我写出这句语言,
都怪我,基础太差!
你就好人做到底,谢谢啦
2007-09-17 18:59
快速回复:[求助]整理速度谱遇到困难,我的程序是哪出错?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031768 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved