help me understanding this code

This is a discussion on help me understanding this code within the C Programming forums, part of the General Programming Boards category; hi a friend of mine gave me this code to explain it to him but i can't read it too ...

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    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. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,588
    Nothing useful is ever gained from writing code like that, it's just there to tease
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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' );

    [edit]
    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.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 30
    Last Post: 06-19-2006, 12:35 AM
  2. Replies: 1
    Last Post: 03-21-2006, 06:52 AM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 11:38 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21