为什么我用图片文件合成,每次都说我图片打不开呢?
#include<stdio.h>#include<stdlib.h>
void main()
{
FILE *picture,*file,*finish;
char picture_name,file_name,finish_name;
char ch;
printf("请输入需要合成的图片和文件的名称:\n");
printf("图片:");
scanf("%s",picture_name);
printf("文件:");
scanf("%s",file_name);
printf("生成的文件名称:");
scanf("%s",finish_name);
if(!(picture=fopen(picture_name,"r")))
{
printf("Cannot open the picture %s !",picture_name);
return;
}
if(!(file=fopen(file_name,"r")))
{
printf("Cannot open the file %s !",file_name);
return;
}
if(!(finish = fopen(finish_name,"w")))
{
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");
}
这是运行的报错,和我要合成的图片和文件,我是初学者求高手教下,万分感谢
本帖最后由 BaiBai2011 于 2014-2-14 13:24 编辑
#include<stdio.h> 本帖最后由 BaiBai2011 于 2014-2-14 13:25 编辑
请注意读用 "rb" 读取二进制文件!请注意写用 "wb"写二进制文件!
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *picture,*file,*finish;
char picture_name,file_name,finish_name;
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");
}
Karl_Doenitz 发表于 2014-2-14 13:10 static/image/common/back.gif
这是运行的报错,和我要合成的图片和文件,我是初学者求高手教下,万分感谢
输入全路径 顶一下哈~
页:
[1]