Mail Archives: djgpp/2002/07/30/03:15:33
From: | "Patrick Chen" <pck66 AT pd DOT jaring DOT my>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | fread can't read a second time.
|
Date: | Tue, 30 Jul 2002 14:23:51 +0800
|
Organization: | Unconfigured
|
Lines: | 47
|
Message-ID: | <ai5bds$2q0$1@news5.jaring.my>
|
NNTP-Posting-Host: | j240.crc23.jaring.my
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 6.00.2600.0000
|
X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2600.0000
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Use C,djgpp. IDE Rhide.
Dear All,
I have this weird problem. The first block will load a red.bmp, open
it, get the header, pass it to process ld_memtofile along with fin to close
it inside the function. Without the second block of open&process green.bmp,
mb[0]->data[234} sample, did receive the right value.
When I put the second block to process the green.bmp,
SIGSEGV general protection fault occur at the fread of the second block. It
cannot transfer the data from green.bmp to file_header_ex2 even though
fileheader_ex2 is a new char array with new fin2 which is not 0. Can some
good people explain why this can happen and how to solve it?
Thank you.
Patrick
int main() {
MOUSEBITMAP *mb[1];
char fileheader_ex[54],fileheader_ex2[54];
FILE *fin,*fin2;
fin=fopen("red.bmp","rb");
if(fin==NULL)
{
printf("Can't open input file\n");
exit(0);
}
fread(fileheader_ex,sizeof(BYTE),54,fin);
ld_filetomem(&mb[0],fileheader_ex, fin);
fin2=fopen("green.bmp","rb");
if(fin==NULL)
{
printf("Can't open input file\n");
exit(0);
}
fread(fileheader_ex2,sizeof(BYTE),54,fin2);// FAULT
ld_filetomem(&mb[1],fileheader_ex2, fin2);
while(!kbhit());
return 0
}
- Raw text -