|
|
10鱼币
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- FILE *f_onefile, *f_anotherfile, *f_finish;
- char temp, onefile_name[100], anotherfile_name[100], finish_name[100];
- printf("Hello, This is a synthesizer:\n");
- printf("One file name:");
- scanf("%s\n", onefile_name);
- printf("Other file name:");
- scanf("%s\n", anotherfile_name);
- printf("Finish file name:");
- scanf("%s\n", finish_name);
- if(!(f_onefile = fopen(onefile_name, "rb")))
- {
- printf("Cannot open the onefile %s", onefile_name);
- exit(1);
- }
- if(!(f_anotherfile = fopen(anotherfile_name, "rb")))
- {
- printf("Cannot open anotherfile %s", anotherfile_name);
- exit(1);
- }
- if(!(f_finish = fopen(finish_name, "wb")))
- {
- printf("Cannot open the finishfile %s", finish_name);
- exit(1);
- }
- while(!(feof(f_onefile)))
- {
- temp = fgetc(f_onefile);
- fputc(temp, f_finish);
- }
- fclose(f_onefile);
- while(!(feof(f_anotherfile)))
- {
- temp = fgetc(f_anotherfile);
- fputc(temp, f_finish);
- }
- fclose(f_anotherfile);
- fclose(f_finish);
- system("pause");
- return 0;
- }
复制代码
两个文件整合成一个,当我用一个jpg和一个rar合并时,jpg显示ok,但是rar就会提示数据损坏。
后来我用jpg和txt合并,jpg还是可以正常显示,但是txt显示出现乱码(txt里面为正常字母,如:lldkjdkf)。
请问大家,这个是因为什么原因造成的呢?
又该如何解决? |
最佳答案
查看完整内容
我复制了你的代码运行了下,rar文件可以正常打开啊,打开后视频也是可以播放的。
是不是编译器的问题,
补充内容 (2012-10-8 21:33):
txt文件不是二进制文件,所以txt文件是乱码。
DOS下用:
copy /b 1.jpg+2.txt 3.txt(/b表示文件是二进制文件)
这样生成的3.txt也是乱码,这不是程序的问题。
|