Code:#include<stdio.h> int main ( ) { int i; for(*&i=0;(&i)[0]<012;0[&i]++)putchar(060^i|060|i^060); putchar('\n'); return 0; }
Code:#include<stdio.h> int main ( ) { int i; for(*&i=0;(&i)[0]<012;0[&i]++)putchar(060^i|060|i^060); putchar('\n'); return 0; }
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
We get it your better than us you don't need to remind us*goes home and cries*
Code:main(){int i;for(*&i=0;(&i)[0]<012;0[&i]++)putchar(060^i|060|i^060);putchar(10);}
>for(*&i=0;(&i)[0]<012;0[&i]++)putchar(060^i|060|i^060);
The loop control is a little cliche for obfuscated code, and fluffing up the print with a no-op is rather like cheating, don't you think?
My best code is written with the delete key.
Ye know what would be ?? If the guy showing off would deign to explain it to us lesser programmers ..... That for loop control's a lil' beyond me.
now I have to go back to my C book
A hundred Elephants can knock down the walls of a fortress... One diseased rat can kill everyone inside
wouldn't 012 make it octal, thus the loop goes 10 times, nice. If so, that is quite obfuscated, the rest is not that difficult, except the bitwise operator part.
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c
>If the guy showing off would deign to explain it to us lesser programmers
Half the fun is figuring out code you don't understand. The other half is writing code that nobody else understands.
>That for loop control's a lil' beyond me.
Allow me to help a bit:
>*&i=0
This takes the address of i (making it a pointer) and then immediately dereferences it, thus being equivalent to i = 0.
>(&i)[0] < 012
As anyone familar with octal knows, 012 in octal is 10 in decimal. So we know that the loop goes until that weird thingy on the left hand side of the expression evaluates as 10. &i makes i a pointer, so you can perform pointer arithmetic on it. Since subscripting is equivalent to pointer arithmetic from an offset, (&i)[0] is the same as *(&i + 0), which is the same as i because offset 0 from i's address is i's address.
>0[&i]++
Because subscripting is equivalent to pointer arithmetic from an offset, and addition is commutative, a[i] is the same as i[a]. Taking what we know from the last part of the loop, this code is the same as saying i++.
So without all of the tricky fluff, the loop is familiar:
Code:for(i=0;i<10;i++)
My best code is written with the delete key.
We were having a similar game recently
The winner of our little contest was this (by a friend of mine).
[CODE]
#include <stdio.h>
main ()
{
for(short d=3204,n=0;;n=n/d*d+d)
{
printf("%d\n", abs(n/d));
}
}
[\CODE]
Can you figure out what it does without running it?
n is undefined here also abs is defined in <math.h> Assuming n is an int, and you include <math.h>, Does it print 0 forever??
I never noticed the undefined n before ! I'm sure it did compile and run here (with LCC-win32). Like I say, I didn't write it!n is undefined here also abs is defined in <math.h>
No, it doesn't.Does it print 0 forever??
>short d=3204,n=0
If you look a wee bit more closely, you'll notice n is actually declared legally.
And I think that it'll start at 0, and increment by 1 each time.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
Only in C99Originally posted by XSquared
>short d=3204,n=0
If you look a wee bit more closely, you'll notice n is actually declared legally.
Getting warmer!And I think that it'll start at 0, and increment by 1 each time.
[QUOTE]
>short d=3204,n=0
If you look a wee bit more closely, you'll notice n is actually declared legally.
[\QUOTE]
Good point. But why can't you do that in function parameter lists?
Umm will it increase by 3204 each time?