Mail Archives: djgpp/1996/10/22/11:11:58
Errors-To: postmaster AT bloomberg DOT com
From: "R.G. Morgan" <R DOT G DOT Morgan AT ncl DOT ac DOT uk>
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 <somefile.c>
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
- Raw text -