# Thread: help me understanding this code

1. ## help me understanding this code

hi
a friend of mine gave me this code to explain it to him
but i can't read it too even with knowing the output
it would be nice if someone could explain me this code

for(char *c="89?9;?8>8::<89@8?<8;:9<<89@8?>8>8::<9<>8?<8;:9 <<8A?9;?8>89<<",i=0;i<=57;i+=3,(i%(*c&1<<3| ~~1 <<2))?*c<<2&i>>1|*c*2: putchar(10)) for( int n=7;n>=0;n--)((*(c+i)-56)*100+((*(c+i+1))-56)*10+(*(c+i+2)-56))&(1<<n)?putchar('@'):putchar(' ');
big thx in advance

2. Nothing useful is ever gained from writing code like that, it's just there to tease

3. Basicly it just goes through a string, does a bit of math on each character, and prints out the resulting character. Probably just to print some message like "I am 1337.". I haven't bothered compiling it, but that's the gist of it.

All of the "*(c+X)" stuff is dereferencing the string 'c' plus X number of bytes down the string. Such as:

char *c = "abcde";

*(c + 3) gives you the letter 'd' from the string. So all they really do is jump to specific spots in the string, pull out that number. Subtract a bit to get a letter or number, or do a bit of other math to get whatever value they want from it, and display that character. The '10' they're putting out is the newline character. It's a way to obfuscate the fact that they're putting a new line to without blatently saying: "putchar( '\n' );

Curses, foiled again. And as Salem said, it never has a practical purpose. Unless you're trying to win an obfuscated code contest.
[/edit]

Quzah.

Popular pages Recent additions