Article View: alt.folklore.computers
Article #5141Re: Ugly source contest
From: cev... C C Evert
Date: Wed, 10 Oct 1990 20:08
Date: Wed, 10 Oct 1990 20:08
39 lines
1715 bytes
1715 bytes
In article <15...@yunexus.YorkU.CA>, rre...@yunexus.YorkU.CA (Richard Reiner) writes:
> We've had stupid program names, stupid programmers errors, and so on;
> now how about getting right down to basics: stupid programs. The
A friend showed me this gem:
#include <stdio.h>
char string_return[256];
char *string3_cat(s1,s2,s3)
char *s1, *s2, *s3;
{
FILE *temp;
if ((temp = fopen("/tmp/string_cat","w")) == NULL)
{ perror("can't open termprary string_cat file for writing--call P
exit(-1);
}
fprintf(temp,"%s%s%s\n",s1,s2,s3);
fclose(temp);
if ((temp = fopen("/tmp/string_cat","r")) == NULL)
{ perror("can't open termprary string_cat file for reading--call P
exit(-1);
}
fscanf(temp,"%s",string_return);
fclose(temp);
unlink("/tmp/string_cat"); /* remove the temp file */
return(string_return);
}
Yikes! Why didn't the author #define /tmp/string_cat? Now that would have
been good programming style. :-)
--
C C Evert
Western Geophysical - A division of Western Atlas International,
A Litton/Dresser Company DOMAIN addr: cev...@airgun.wg.waii.com
UUNET address: uunet!airgun!cevert
Technical Details
Message-ID:
<892@airgun.wg.waii.com>Path:
mbox-mo1.pugleaf.net!gmdzi!unido!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!airgun!cevertReferences:
<15827@yunexus.YorkU.CA>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!gmdzi!unido!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!airgun!cevert From: cev...@airgun.wg.waii.com (C C Evert) Newsgroups: alt.folklore.computers Subject: Re: Ugly source contest Summary: Leonard Pinth Garnell for 'Bad Program' Message-ID: <892@airgun.wg.waii.com> Date: 10 Oct 90 20:08:33 GMT References: <15827@yunexus.YorkU.CA> Organization: Western Geophysical, Houston Lines: 39 Posted: Wed Oct 10 21:08:33 1990 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit