我现在需要一个小程序,完成遇到逗号(,)就换行的操作就行,
提示while语句没有申明!我是新手,现在急需处理数据,没有时间去摸,请高手指点!!!
谢谢
#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[20];
FILE *fin,*fout;
if((fin=fopen(infile,"r"))==NULL)
{
printf("can't open input file\n");
exit(1);
}
if((fout=fopen(outfile,"w"))==NULL)
{
printf("can't open output file\n");
exit(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);
}
}
while (scanf char(20)==",")
printf ("\n"); 遇到逗号就换行的语句 提示while语句没有申明!
fclose(fin);
fclose(fout);
return 0;
}