我正在写一个C程序,它读取(http://smsoftdev-solutions.blogspot.com.au/2014/07/code-for-reading-bmp-image-files.html)之后的bmp图像的宽度和高度。但是我在终端遇到了错误,它表明:
i './a.out' terminated by signal SIGSEGV (Address boundary error)
我做了一些谷歌搜索,他们提到它访问额外的内存问题,但我无法在我的代码中发现,任何建议都会受到赞赏
#include <stdio.h>
struct __attribute__((__packed__)) BitmapHeader
{
int width;
int height;
};
void loadBmp(char* filePath, struct BitmapHeader bmpHeaderInfo){
FILE* filePtr = fopen(filePath, "rb");
unsigned char header[54];
fread(header, sizeof(unsigned char), 54, filePtr);
}
int main(){
char path2BMP[] = "/cup.bmp";
struct BitmapHeader bmpHeaderInfo = {0};
loadBmp(path2BMP, bmpHeaderInfo);
return 0;
}