|
发表于 2014-2-14 13:18:03
|
显示全部楼层
本帖最后由 BaiBai2011 于 2014-2-14 13:25 编辑
请注意读用 "rb" 读取二进制文件!请注意写用 "wb" 写二进制文件!
- #include<stdio.h>
- #include<stdlib.h>
- void main()
- {
- FILE *picture,*file,*finish;
- char picture_name[20],file_name[20],finish_name[20];
- char ch;
- printf("请输入需要合成的图片和文件的名称: \n");
- printf("图片: ");
- scanf("%s",picture_name);
- printf("文件: ");
- scanf("%s",file_name);
- printf("生成的文件名称: ");
- scanf("%s",finish_name);
- if(!(picture=fopen(picture_name,"rb")))
- {
- printf("Cannot open the picture %s !",picture_name);
- return;
- }
- if(!(file=fopen(file_name,"rb")))
- {
- printf("Cannot open the file %s !",file_name);
- return;
- }
- if(!(finish = fopen(finish_name,"wb")))
- {
- printf("Cannot open the finish %s !",finish_name);
- return;
- }
- while(!(feof(picture)))
- {
- ch = fgetc(picture);
- fputc(ch,finish);
- }
- fclose(picture);
- while(!(feof(file)))
- {
- ch = fgetc(file);
- fputc(ch,finish);
- }
- fclose(file);
- fclose(finish);
- system("pause");
- }
复制代码
|
|