我编了个,你看看
#include<stdio.h>
#include<string.h>
#include <process.h>
int main()
{
FILE *fp1,*fp2;
char a[100],b,c[10];
int count=0,i=0,k=0,flag1=0,flag2=0;
fp1=fopen("222.txt","r");
if(fp1==NULL)
{
printf("打开失败!");
exit(0);
}
fp2=fopen("111.txt","w+");
if(fp2==NULL)
{
printf("打开失败!");
exit(0);
}
while(!feof(fp1))
{
b=fgetc(fp1);
if(b<'0'||b>'9')
putc(b,fp2);
else if(b>'0'&&b<'9')
{
putc(b,fp2);
count++;
flag1=1;
}
if(flag1&&b==' ')
{
flag1=0;
if(count<=4)
{
fseek(fp2,-(count+2),1);
fputc('\n',fp2);
fseek(fp2,0,2);
continue;
}
else
count=0;
}
}
}