|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include <string.h>
#include <stdlib.h>// because use exit();
int main ()
{
FILE *fp;
FILE *rp;
FILE *cp;
char filename1[256];
char filename2[256];
char filename3[256];
//起始输入部分
lable1:;
printf("please input the first filename:\n");
gets(filename1);
fp=fopen(filename1,"rb");
if (NULL==fp)
{
printf("the first file open fail!!\n");
//exit(0);
goto lable1 ;
}
lable2:;
printf("please input the second filename:\n");
gets(filename2);
rp=fopen(filename2,"rb");
if (NULL==rp)
{
printf("the second file open fail!!\n");
//exit(0);
goto lable2 ;
}
lable3:;
printf("please input the filename you want keep:\n");
gets(filename3);
cp=fopen(filename3,"ab+");
if (NULL==cp)
{
printf("the file crate fail!!\n");
//exit(0);
goto lable3 ;
}
printf("writing……");
//文件写入部分
int ch1;
ch1=fscanf(fp,"%d",&ch1);
while (feof(fp))
{
fprintf(cp,"%d",ch1);
ch1=fscanf(fp,"%d",&ch1);
}
printf("the first file write success.\n");
int ch2;
ch2=fscanf(rp,"%d",&ch2);
while (feof(rp))
{
fprintf(cp,"%d",ch2);
ch2=fscanf(rp,"%d",&ch2);
}
printf("the second file write success.\n");
fclose(fp);
fclose(rp);
fclose(cp);
return 0;
}
通过上面的代码,我把a.jpg和a.txt做成了q.txt
但是当我把q的后缀改成 .rar 时,用好压倒不开呀
|
|