Home > Software engineering >  The error of fopen to open the file
The error of fopen to open the file

Time:10-09

Call a function to write the file, the function to the fopen, always report the errors shown in the figure, what reason is this excuse me?
 
# define FLT_MAX 4095
Char cfile [_MAX_PATH];
Strcpy (cfile, "TV. Bin");
WriteBin (cfile iterimg, sliceW sliceW);



Bool writeBin (char * Filename, float * Image, int width, int height) {
BIN_HEADER HDR;
The float=0, Max min=FLT_MAX;
The FILE * fp.
Fp=fopen (Filename, "wb");
If (fp==NULL) {
Printf (" the File open error!" );
return 0;
}
Int size=width * height * sizeof (float).
For (int j=0; J & lt; The size/sizeof (float); J + +)//find maximum and minimum pixel
{
If (* (Image + j) & gt; Max) Max=* (Image + j);
If (* (Image + j) & lt; Min) min=* (Image + j);
}
HDR. Min=min;
HDR. Max=Max;
HDR. Width=width;
HDR. Height=height;
HDR. The depth=frame;

Fwrite (Image, sizeof (float), width * height, fp);
Fwrite (& amp; HDR, sizeof (BIN_HEADER), 1, fp);//write header file
Int ErrorCode=fclose (fp);
If (ErrorCode!=0)
{
Printf (" the File close error!" );
return 0;
}
return 1;

}


CodePudding user response:

Image space is not large enough, I guess,

Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until we can read ,

CodePudding user response:

What is the Filename and path if there's any problem
Error is handle is not correct,

CodePudding user response:

Filename is the name of the file, this is a TV in the bin, I want to create a new name for TV. The bin binary file, and then to write the data, but the correct procedure

CodePudding user response:

Not because fopen printf (" the File open error!" ); Didn't come out

CodePudding user response:

Well, the same code, run on the Mac is no problem, run on VS2010 would put the error, the latest system updates on WIndows has been uninstalled

CodePudding user response:

After the breakpoint, F10 by process debugging, see which one operation error

CodePudding user response:

WriteBin (cfile iterimg, sliceW, sliceW );
2 W? Height?
  • Related