loading bmps

I am trying to losd a bmp file that I want to apply to a rectangle.here is some code I am working on.

int LoadBitmap(LPTSTR szFileName, GLuint &texid, int width, int height)
// Creates Texture From A Bitmap File
unsigned char tex[1001003 + 183]; //array to hold data input
unsigned char tex2[100
100*3]; //array to hold texture data
unsigned char temp; //swap variable

int num; //loop variable
FILE * f; //open the bitmap for reading

if ((f=fopen(szFileName,“r”))== NULL)
{return 1;}
fread(tex,widthheight3 + 18*3,1,f); //read data from bitmap

fclose(f); //close the file

for (num = 183-1; num < widthheight3 +183; num = num + 1)
//remove the first 18 pixels, RGB code = 3 bytes
tex2[num - 18*3] = tex[num];

for (num = 0; num < widthheight3; num = num + 3)
//bitmap backwards so change BGR code to RGB code
//by swaping the every third bit with evert first.
temp = tex2[num];
tex2[num] = tex2[num+2];
tex2[num +2] = temp;

glBindTexture(GL_TEXTURE_2D, texid); //select ID to store the texture
glTexImage2D(GL_TEXTURE_2D, 0,3, width ,height, 0,GL_RGB, GL_UNSIGNED_BYTE, tex2);
//produce the texture
return 0;