Do your worst

C

CBFalconer

Additions welcome. Without further ado, I present.

/* ---------- worst.c -----------*/

/* The objective here is to include as many C errors as
possible, without triggering the compiler into objecting.
I have tried to get an error into each line. Logical
foulups count. The test compiler is gcc 3.2.1, executed
with "gcc worst.c", i.e. with absolutely no extra warning
enabled, and linking successfully.
I have tried for at least one error per line. However
some variable declarations remain completely valid */

#define EOF -1
#define stdin 0

main()
{
int x, y;
char c;
char *fmt = "%d, %l";
unsigned int z;

while (!feof()) {
c = getchar();
if (EOF == c) continue;
}
gets(&c);
printf(fmt, &c, x);
fflush(stdin);
fmt = (char *)malloc(123);
fmt = (char *)realloc(fmt, 245);
y = fmt[1000];
for (z = 10; z >=0; z--) x += z;
if (z > 0) return -1;
} /* worst main */
 
A

Aggro

CBFalconer said:
for (z = 10; z >=0; z--) x += z;

I think you should leave the z assignment out (z = 10) to get better
performance.

Also, how about some neet function calls? You can screw up several
things when creating and calling your own functions. Or is the plan to
stick with the main()?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top