|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 阿飞。 于 2016-3-21 21:45 编辑
以上代码是我自己写的,和小甲鱼的有点不一样,我想知道和图片合成的文件必须是rar格式的吗?我试了zip和txt文件都不行,运行后新文件就会变成图2中那样,为什么呢
- #include<stdio.h>
- #include<stdlib.h>
- int main()
- {
- FILE *p,*f,*n;
- char ch,picture_name[50],file_name[50],new_name[50];
- printf("输入要合体的文件名:\n");
- printf("图片名:");
- scanf("%s",picture_name);
- if((p=fopen(picture_name,"rb"))==NULL)
- {
- printf("cannot open file!\n");
- exit(0);
- }
- printf("\n文件名:");
- scanf("%s",file_name);
- if((f=fopen(file_name,"rb"))==NULL)
- {
- printf("cannot open file!\n");
- exit(0);
- }
- printf("\n新文件名:");
- scanf("%s",new_name);
- n=fopen(new_name,"wb");
- while(!feof(p))
- {
- ch=fgetc(p);
- fputc(ch,n);
- }
- fclose(p);
- n=fopen(new_name,"wb");
- while(!feof(f))
- {
- ch=fgetc(f);
- fputc(ch,n);
- }
- fclose(f);
- fclose(n);
-
- return 0;
- }
复制代码 |
|