Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!nbires!isis!udenva!skajihar
From: skajihar@udenva.UUCP ("Lord of Sith" Kajihara)
Newsgroups: comp.lang.c,comp.lang.fortran,comp.lang.misc,comp.lang.modula2
Subject: Re: Collecting favorite bug stories
Message-ID: <2722@udenva.UUCP>
Date: Mon, 12-Jan-87 12:26:13 EST
Article-I.D.: udenva.2722
Posted: Mon Jan 12 12:26:13 1987
Date-Received: Tue, 13-Jan-87 04:40:52 EST
References: <3669@curly.ucla-cs.UCLA.EDU>
Reply-To: skajihar@udenva.UUCP ("Lord of Sith" Kajihara)
Distribution: world
Organization: U of Denver
Lines: 61
Xref: mnetor comp.lang.c:669 comp.lang.fortran:52 comp.lang.misc:134 comp.lang.modula2:84

In article <3669@curly.ucla-cs.UCLA.EDU> you write:
>I am collecting anecdotes of experiences, (real or imagined) 
>for a book to be titled:
>
>    MY FAVORITE BUGS: Humourous, and Horrible Experiences in Software
>                      Engineering.
>
>As one might tell from the title, the book will be filled with wonderful
>tales that programmers tell each other, over a few too many beers,
>after a long day at the keyboard.
>

Sorry about posting this, but we do not support ARPA here.

I don't know that this qualifies for what you ask, but the following comes
from an inexperience with C and file processing.

I had a program that would read from n text files and write to an output file.
The first time that I ran the program, I exceeded the amount of disc quota I
had on the system.

The problem:  in using command-line arguments to identify my files, I had
inadverdently included my output file as input.  Result:  an endless loop.

In the following code, argc is the number of arguments to the program, argv
is an array of character pointers.  argv[argc-1] is the output file.

     .
     .
     .

     for (inc = 1; inc <= argc-1; ++inc)

        process(argv[inc],argv[argc-1]);

     .
     .
     .

The solution is to make the condition of the for loop '<' rather than '<='.

I am only an undergraduate physics major so forgive me for my modest and
possibly trivial solution.

      Scott Kajihara


-- 
________________________________________________________________________________

     Me?  A CS major?  Now, I know that either you are joking or LAKking.

      -- Scott Kajihara

      UUCP:  ...!udenva!skajihar

     Disclaimer:  the above quote is not meant to insult computer science types;
                  it is just that I could never become CS and remain my usual
                  insane self (they have always said that we are strange but
                  have charm).
________________________________________________________________________________