We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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<
hi
i looked to the code but it is very complicated and i do not understand what it calculates .
but i have fixed the code and it compiles and it now works.
#include <stdio.h> #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; // .. printf ( "the variable is %d\n", i ); return 0; END
thnx jelma you are the diamend!
I mean, are you kidding us?
i = 0; i == 10 ? 0 : -1
Dear god,
Please keep these brilliant minds far away from mission critical systems, hence: * Flight control systems * Weapon guidance * Navigation * To keep Per Westermark happy, please also keep them away from digital cameras... * ...
I would be happy to let them write software for my blender.
See you soon.
for (i = 0; i == 10 ? 0 : -1 ; INC ( i ) )
Tamir,
Ok, this line of code is terribly ugly and it is an extract from something written by someone who obviously should consider a career in something other than software ...
... But I cannot see what is technically wrong with the test expression. -1 is non-zero, therefore the test equates to true.
My head is spinning from the implications of the above code.
That for loop line:
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 :)
"I would be happy to let them write software for my blender."
Blender as in "chop your fingers off when not in use because it randomly auto-starts?"
Or blender as in "today, the fire truck came to visit - seems my blender was running for five hours straight and finally overheated and caught fire?"
well, there is nothing technically wrong with this NOW. but what would happen if one will see the light and count down...? I bet je 2 bottles of scotch that somebody will create an out-of-bounds error - that might happen implicitly, in an innocent looking piece of code.
:-)
ok, ok, you win...a blender was just a figure of speech...
Hm ... how about software for kids toys, then? If Talking Elmo's software has a small hiccup and says "Kill James!", at least no one gets physically hurt.
(google "elmo threat" for the real story. :P )
Holy cow, Christoph !
www2.tbo.com/.../