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<
Erm. What language is that, then?
To me, it looked like "C written by someone who'd rather do PASCAL instead".
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.
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.
View all questions in Keil forum