Home > Back-end >  Code debugging
Code debugging

Time:12-24

Why code debugging not to come out with vs2019
#include
#include
#include
#include
//right click on the properties of the project, the configuration properties of c/c + +, code generation, structure member aligned
//select "1 byte
"Struct bmpFileHeader
{
Short bfType;//0 x00 starting offset
Int bfSize;//0 x02//file size
Int bfReserve;//0 x06
Int bfoffBits;//0 x0a
Int bitSize;//0 x0e is 40
Int biWidth; * * * *////0 x12 bitmap width
Int biHeight;//0 x16 high * * * * *//bitmap
Short biPlanes;//0 x1a 1
Short biBitCount; * * * *////0 x1c USES color figures, can be 1,2,4,8,16,24, new can be 32
Int biCompression;//0 x1e//compression way, can be 0, where 0 means no compression
Int biSizeImage;//0 x22//the actual bitmap data takes up the number of bytes
Int biXPlosPerMeter;//0 x26
Int biYPlosPerMeter;//0 x2a
Int biClrUsed;//0 x2e
Int biClrImportant;//0 x32
} the header;
Int comp_linesize (struct bmpFileHeader * pheader)
{
int sum=0;
Sum=pheader - & gt; BiWidth;
The sum *=3;
If (sum % 4==0) return the sum.
If (sum % 4! Sum +==0) 4 - (sum % 4); Return the sum.
}
Void printMsg (struct bmpFileHeader * pheader)
{
Printf (" image width: % d \ n high image: % d \ n % d scan line size: \ n ", the header. The biWidth, header. BiHeight, comp_linesize (& amp; The header));
}
Int main ()
{
Printf (" please enter the file name: \ n ");
Char file1 [100].
Scanf_s (" % s ", "); The FILE * FPL;
FPL=fopen (file1, "rb");
If (FPL==NULL)
Open failure {printf (" % s ", "); return 0;
}
Fread (& amp; The header, sizeof (struct bmpFileHeader), 1, FPL); Int linesize=comp_linesize (& amp; The header);
Int txsize=linesize * header. BiHeight;
Char * bmpbody=(char *) malloc (txsize);
Fread (bmpbody txsize, 1, FPL); PrintMsg (& amp; The header); The fclose (FPL);
return 0;
}
  • Related