|
#include<stdio.h>
#include<string.h>
#include<conio.h>
char xx[50][80];
int maxline=0;
int ReadDat(void);
void WriteDat(void);
void StrOR(void)
{
{int i;
char yy[80],*p;
for(i=0;i<maxline;i++)
{p=strchr(xx,'o');
while(p!=NULL)
{
memset(yy,0,80);
memcpy(yy,xx,p-xx);
strcpy(xx,xx+(p-xx)+1);
strcat(xx,yy);
p=strchr(xx,'o');
}
}
}
}
void main()
{clrscr();
if(ReadDat())
{printf("数据文件IN.DAT不能打开!]n\007");
return;
}
StrOR();
WriteDat();
}
int ReadDat(void)
{FILE*fp;
int i=0;
char*p;
if((fp=fopen("IN.DAT","r"))==NULL)return 1;
while(fgets(xx,80,fp)!=NULL)
{p=strchr(xx,'\n');
if(p)*p=0;
i++;
}
maxline=i;
fclose(fp);
return 0;
}
void WriteDat(void)
{FILE*fp;
int i;
clrscr();
fp=fopen("OUT5.DAT","w");
for(i=0;i<maxline;i++)
{printf("%s/n",xx);
fprintf(fp,"%s\n",xx);
}
fclose(fp);
}
个人感觉这个用脚本实现起来应该比用c程序简单吧,有人能做出吗,谢谢 |
|