From: "Patrick Chen" Newsgroups: comp.os.msdos.djgpp Subject: Re: fread can't read a second time. Date: Thu, 1 Aug 2002 01:43:55 +0800 Organization: Unconfigured Lines: 29 Message-ID: References: <3D479194 DOT 3998CB1B AT acm DOT org> NNTP-Posting-Host: j120.crc22.jaring.my X-Trace: news4.jaring.my 1028137437 22560 61.6.159.134 (31 Jul 2002 17:43:57 GMT) X-Complaints-To: usenet AT news4 DOT jaring DOT my NNTP-Posting-Date: 31 Jul 2002 17:43:57 GMT 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 Thank you for responding, I finally get it solved. The fault pointed by the compiler at the second fread is not the actual place of error. Error lies somewhere in the function of the function. There were mallocs in it and possibly multiple call of malloc cause the fault. I have them taken out and declare global for malloc pointers and correct some other errors as well. So they run ok now. Patrick "Eric Sosman" wrote in message news:3D479194 DOT 3998CB1B AT acm DOT org... > Patrick Chen wrote: > > [...] > > When I put the second block to process the green.bmp, > > SIGSEGV general protection fault occur at the fread of the second block. > > Are you sure the second fopen() succeeds? Notice that > the program does *not* check for its success or failure: > > > fin2=fopen("green.bmp","rb"); > ^^^^ > > if(fin==NULL) > ^^^ > > -- > Eric Sosman > esosman AT acm DOT org