Subject: Re: Need help with c! Approved: clc AT plethora DOT net References: From: Francis Glassborow X-Newsreader: Turnpike (32) Version 3.05 Organization: Southfield Microcomputer SS Lines: 47 Mime-Version: 1.0 Newsgroups: comp.os.msdos.djgpp,comp.lang.c.moderated Message-ID: Originator: clcm AT plethora DOT net (Comp Lang C'Moderated) Date: Mon, 18 Jan 1999 19:00:01 GMT NNTP-Posting-Host: 205.166.146.5 X-Trace: ptah.visi.com 916686001 205.166.146.5 (Mon, 18 Jan 1999 13:00:01 CDT) NNTP-Posting-Date: Mon, 18 Jan 1999 13:00:01 CDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com My compliments on actually trying to walk your code. Howevee there are a number of warts (such as writing void main() ) that I guess others will point out to you. However you have walked into a well known trap which I highlight below: In article , Mohanaraj Gopala Krishnan writes >void open_file(int * pages_done, int array_size) Would be a good idea to have this function return a suaccess/failure indicator >{ > int i=0; > > if((fptr=fopen("chapter.dat", "r")) !=NULL) { > >fseek(fptr,0L,SEEK_SET); > >for(i=0;i >fscanf(fptr,"%d",*(pages_done++)); but here we have a very nasty trap pages_done was a pointer to an int (I guess it is to be an array) that means *(pages_done++) evaluates to the CONTENTS of the current address in pages_done before incrementing the address. But if you check fscanf you will find that it needs an address of an int. you need to write: fscanf(fptr,"%d", pages_done+i); You could use the increment operator but I find the base+offset better in this type of situation, though that is a matter of personal style. > >} Francis Glassborow Chair of Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation -- comp.lang.c.moderated - clcm AT plethora DOT net