throws exception when trying to use pointer to store unsigned chars in array
Code:
unsigned char texture1 = 2700000;// 262 144;
the function :
I am stuck with not finding a solution now after trying different thing for a while
Code:
int readbmp() {
fileheader bmpheader;
infoheader bmpinfoheader;
unsigned char *p,*p2;
p =&texture1;
unsigned char header[100];
int f, i, j,cnt;// buffer[10961024];
cnt = 0;
//char str[2000];
unsigned char c;
f = 2048;
ifstream fileread("test.bmp",ios::binary);
//ifstream fileread("test.txt");
//read in 40 bytes header
cout << "fileheaders";
for (j = 0; j < (40+14); j++) {
fileread >> c;
header[j] = c;
i = (int)c; i = i & 0xff;
cout << i << "\n";
}
i = 0x001c;
if (header[i] = 24) {
cout << "24bit bmp ";
cout << "bitmapdata";
while (!fileread.eof()) {
fileread >> c;
(*p) = c;//exception always here
++p;
//cout << c;
f--;
//if (f == 0) break;
}
}
else {
cout << "8bit palette bmp \n";
}
fileread.close();
return 1;
}