Home > Back-end >  Help: why doesn't picture1 open?
Help: why doesn't picture1 open?

Time:09-15

#include
#include
Void main ()
{
F_file f_pic FILE * and * and * f_finish;
Char ch, pic_name [20], file_name [20], finish_name [20].

Printf (" shurutupianhewenjian \ n ");
Printf (" picture: ");
The scanf (" % s ", pic_name);
Printf (" file: ");
The scanf (" % s ", file_name);
Printf (" result: ");
The scanf (" % s ", finish_name);

if(! (f_pic=fopen (pic_name, "rb")))
{
Printf (" always open the picture % s!" , pic_name);
return;
}
if( ! (f_file=fopen (file_name, "rb")))
{
Printf (" always open the file % s!" , file_name);
return;
}
if(! (f_finish=fopen (finish_name, "wb")))
{
Printf (" always open the file % s!" , finish_name);
return;
}
while (! (feof (f_pic)))
{
Ch=fgetc (f_pic);
Fputc (ch, f_finish);
}
The fclose (f_pic);
while (! (feof (f_file)))
{
Ch=fgetc (f_file);
Fputc (ch, f_finish);
}
The fclose (f_file);
The fclose (f_finish);
System (" pause ");
}

C: \ Users \ \ Administrator \ CLionProjects \ 73 \ cmake - build - the debug \ 627840. Exe
Shurutupianhewenjian
Picture: 1. JPG
File: 2. Rar
Result: 3. JPG
Always open the picture 1. JPG!
Process is over, the exit code 0


CodePudding user response:

May 1. JPG does not exist

CodePudding user response:

In the following way to print, can know the reason for the error

 if (! (f_file=fopen (file_name, "rb"))) 
{
Printf (" always open the file % s!" , file_name);
Printf (" % s \ n ", the strerror (errno) :
return;
}

Note, every open file Suggestions with it, and need to introduce string. H and errno. H header file

CodePudding user response:

Image or not, I just download from the Internet, access problem?
  • Related