This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

what Is wrong With This code

i tried this code and it is failes! what is wrong?


#define BEGIN  {          // use proper blocks
#define END    }

#define INC ( i) i = i + 1   // invrement variable i


int* testtest()
BEGIN
    int  buf1 [ 10 ];             // make a buffer of variables
    int * buf2  10 ] ;        // and make a copy for pointing

    int i ;                           // use a variable to count

    for (i = 0; i == 10 ? 0 : -1 ; INC ( i ) )  // nullify variabel to zero
    BEGIN
        buf1 [ i ] = i;          / / save variable to buffer
        * buf2 [ i ] = & i;              // save variable to other one
    END;

    // ..

  println ( 'the variable is ' + i )
END;
<pre<


Parents
  • My head is spinning from the implications of the above code.

    That for loop line:

    for (i = 0; i == 10 ? 0 : -1 ; INC ( i ) )
    


    just _must_ come from an obfuscated C contest. Was the author thinking that the expression i < 10 was too easy to read? And mixing Pascal into it can't be an explanation.

    Why fill an array of pointers with the address of the single loop variable? For redundancy when some other memory-overwriting accident hits the program?

    Comments should help explain _why_ something is done - if it isn't obvious. But comments saying what the code line does can only imply that the original author do not know what the line does. In this case, we _know_ that the OP do not know what the individual lines does.

    Tamir: I do love cameras, and want to protect them from harm in any way I can :)

Reply
  • My head is spinning from the implications of the above code.

    That for loop line:

    for (i = 0; i == 10 ? 0 : -1 ; INC ( i ) )
    


    just _must_ come from an obfuscated C contest. Was the author thinking that the expression i < 10 was too easy to read? And mixing Pascal into it can't be an explanation.

    Why fill an array of pointers with the address of the single loop variable? For redundancy when some other memory-overwriting accident hits the program?

    Comments should help explain _why_ something is done - if it isn't obvious. But comments saying what the code line does can only imply that the original author do not know what the line does. In this case, we _know_ that the OP do not know what the individual lines does.

    Tamir: I do love cameras, and want to protect them from harm in any way I can :)

Children