skabdulravoof
MIS
hi guys...here i am trying to read bmp file & when i run this code in turbo c ..its wokring properly when it comes to vc++ compiler i got winxp assertion window.. i think i did somthing wrong with pointers..can u help me out plzzz
#include<stdio.h>
#include<conio.h>
typedef unsigned long lword;
typedef unsigned short word;
typedef unsigned char byte;
typedef struct bmpheader
{
char type[2];
lword size;
lword reser;
lword offset;
lword headersize;
lword width;
lword height;
lword planes;
}bmp_header;
int main()
{
int i,x,y;
int result;
char *filename;
bmp_header *bmp_ptr;
clrscr();
printf("enter file name");
scanf("%s",filename);
result=bmp_load(filename,bmp_ptr);
printf("\nvalid_0 invalid_1 bmpfile %d ",result);
}
int bmp_load(char *filename,bmp_header *bmp_ptr)
{
FILE *fp;
bmp_ptr->type[0]=' ';
if((fp=fopen(filename,"rb"))==NULL)
{
printf("cant open file");
return(1);
}
fread(&bmp_ptr->type,2,1,fp);
if((bmp_ptr->type[0]!='B')||(bmp_ptr->type[1]!='M'))
return(1);
fread(&bmp_ptr->size,52,1,fp);
if(bmp_ptr->headersize!=40)
return(1);
printf("\ndata\t %lu",bmp_ptr->width);
fclose(fp);
getche();
}
#include<stdio.h>
#include<conio.h>
typedef unsigned long lword;
typedef unsigned short word;
typedef unsigned char byte;
typedef struct bmpheader
{
char type[2];
lword size;
lword reser;
lword offset;
lword headersize;
lword width;
lword height;
lword planes;
}bmp_header;
int main()
{
int i,x,y;
int result;
char *filename;
bmp_header *bmp_ptr;
clrscr();
printf("enter file name");
scanf("%s",filename);
result=bmp_load(filename,bmp_ptr);
printf("\nvalid_0 invalid_1 bmpfile %d ",result);
}
int bmp_load(char *filename,bmp_header *bmp_ptr)
{
FILE *fp;
bmp_ptr->type[0]=' ';
if((fp=fopen(filename,"rb"))==NULL)
{
printf("cant open file");
return(1);
}
fread(&bmp_ptr->type,2,1,fp);
if((bmp_ptr->type[0]!='B')||(bmp_ptr->type[1]!='M'))
return(1);
fread(&bmp_ptr->size,52,1,fp);
if(bmp_ptr->headersize!=40)
return(1);
printf("\ndata\t %lu",bmp_ptr->width);
fclose(fp);
getche();
}