#include<stdio.h>
#define SRCFILE "./srcfile"
#define DESFILE "./desfile"
int c_openfile( FILE *file,char *path,char *mode)
{
if((file =fopen(path,mode))==NULL)
{
printf("error open file [%s] ",path);
file =NULL;
return -1;
}
return 0;
}
void main()
{
FILE *src,*des;
int i,j=0;
char *result;
int len=0;
int c=0;
char str[1024];
int s=0;
if((src =fopen(SRCFILE,"r"))==NULL)
{
exit(-1);
}
if((result =(char *)malloc(1024*sizeof(char)))==NULL)
{
printf("malloc result is error");
exit(-1);
}
while(feof(src)==0)
{
fscanf(src,"%s",str);
printf("%s\n",str);
len =strlen(str);
for(i =0;i<len;)
{
result[j++]=str[i];
i +=6;
}
}
printf("result:%s\n",result);
if((des =fopen(DESFILE,"rw+"))==NULL)
{
exit(-1);
}
if(fputs(result,des)==EOF)
{
printf("error write");
exit(-1);
}
printf("write over!!!");
free(result);
fclose(src);
fclose(des);
}
这个没有考虑的很全,应该是以实现你的的需要的功能。
测试平台:unix
有问题请qq:153612021
[
本帖最后由 gavinsurekam 于 2010-12-25 15:18 编辑 ]