i am doing some stuff on image processing on c++. unfortunately i am getting a problem with 2d arrays. i have consulted internet and found how to use 2d arrays properly but still getting the error. i am pasting my code, highlighting the error in red.
thanx
Code:
# include <stdio.h>
# include <iostream>
using std :: cout;
using std :: endl;
void main ()
{
int ch;
int i;
unsigned int h[50], filesize, width,height, validity, bpp, sod, h[2000][2000], col, row ;
FILE *fp;
fp= fopen ("c:\\lena512.bmp", "r"); ///ADDRESS OF FILE.
if (fp == NULL)
puts("not possible");
//while((ch = fgetc(fp)) != EOF)
for (i=0; i<=30; i++)
{
ch = fgetc(fp);
h[i]= ch;
}
validity= h[0] + 256*h[1];
if (validity== 19778)
cout << " it is a valid BITMAP FILE "<<endl<<endl<<endl;
filesize= h[2]+ 256*h[3]+ 256*256*h[4]+ 256*256*256*h[5];
cout<< "FILE SIZE ***************************** "<< filesize << " bytes"<<endl<<endl<<endl;
width= h[18] + 256*h[19] + 65536*h[20] + 16777216*h[21];
height= h[22]+ 256*h[23]+ 65536*h[24]+ 16777216*h[25];
cout<< "DIMENSIONS(wid x hei) ***************** "<< width <<" x "<< height<< endl<<endl;
bpp= h[28]+ 256*h[29];
if (bpp==1)
cout << "monochromatic";
if (bpp==4)
cout<< "16colour";
if (bpp==8)
cout<< "256colour";
if (bpp==16)
cout<< "64k colour";
if (bpp==24)
cout<< "16million colour";
sod = h[10] + 256*h[11]+ 65536*h[12]+ 16777216*h[13];
cout <<endl<< "sod"<< sod;
fclose(fp);
cout << endl<<"end";
for (row=sod; row<=width; row++)
for(col=0; col<=height; col++)
{
ch = fgetc(fp);
h[row][col]= ch; error:subscript requires array or pointer type
}
while(1);
}