From: kagel AT quasar DOT bloomberg DOT com Date: Tue, 22 Oct 1996 10:39:01 -0400 Message-Id: <9610221439.AA04555@quasar.bloomberg.com > To: R DOT G DOT Morgan AT ncl DOT ac DOT uk Cc: djgpp AT delorie DOT com In-Reply-To: <54fgop$eoe@whitbeck.ncl.ac.uk> (R.G.Morgan@ncl.ac.uk) Subject: Re: Laugh at my mistakes (Errors you wish you're mother told you about) Reply-To: kagel AT dg1 DOT bloomberg DOT com Errors-To: postmaster AT bloomberg DOT com From: "R.G. Morgan" Newsgroups: comp.os.msdos.djgpp Date: 21 Oct 1996 09:46:01 GMT Organization: University of Newcastle upon Tyne Lines: 32 Distribution: world Nntp-Posting-Host: glen7.ncl.ac.uk Dj-Gateway: from newsgroup comp.os.msdos.djgpp Content-Type: text Content-Length: 897 I've been programming C for a little while now, and have more or less completed my first non-trivial program. During this process I tore out (metaphorically) much hair due to these mistakes: 1) int i; for (i = 0; i < SOME_NUMBER; i++); { .... } I wonder why that loop only executes once? 2) FILE *fp; /* far, far away */ ... fflush(NULL); intended to flush all streams, an uninitialised FILE pointer causes a SYSSEG on execution. 3) #include Of course I meant .h, but with hundreds of "previously defined" errors spraying out of gcc, this took some time to spot. In all these cases the compiler (rightly) generated no warning. My question is, does anyone else know of any similar mistakes I might make so that I recognise them when the errors start to flow ? OH tons! How about: i=3; if (i = 0) ... else printf("Why doesn't this ever execute?\n"); Or: done=0; while(done=0) { if (!read(.....)) done = 1; .... printf( "When will it ever end? Done = %d.\n", done ); } printf( "Never gets here!\n"); Just for starters. Welcome to 'C'. Have fun! -- Art S. Kagel, kagel AT quasar DOT bloomberg DOT com A proverb is no proverb to you 'till life has illustrated it. -- John Keats