I was writing a C program that reads the width and heights of a bmp image following (http://smsoftdev-solutions.blogspot.com.au/2014/07/code-for-reading-bmp-image-files.html). But I've met an error in terminal, it shows that:
i './a.out' terminated by signal SIGSEGV (Address boundary error)
I did some googling, they mention it's accessing extra memory problem, but I can't really find that in my code, any suggestion would be appreciated
#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;
}