Code:
#include <iostream>
int i;
int main( void )
{
i = 3;
for(;;)
{
/* INSERT LINE HERE TO MAKE MAIN() RETURN 3 - LINE MUST BEGIN WITH i */
i = 2;
break;
}
return 0;
}
Printable View
Code:
#include <iostream>
int i;
int main( void )
{
i = 3;
for(;;)
{
/* INSERT LINE HERE TO MAKE MAIN() RETURN 3 - LINE MUST BEGIN WITH i */
i = 2;
break;
}
return 0;
}
if (i != 0) return 3;
;) good one - I was thinking of 'i' as in the variable, 'i' and not as in 'i'f
It might be fun to stipulate that you cannot use the return keyword in the line of code..
::evil laugh::
Damn I've got to think how to do that in assembly and start the line with i. Maybe // i before the asm block with suffice. Yeah, that'll do.
Maybe? Feel free to slap the assembly amateur :)Code://i
__asm {
cmp i, 0
je contin
mov eax, 3
ret
contin:
}
EDIT: Cool-August, why the hell is i global?
i; return 3;
EDIT:Does kermit == Cool-August?
Code:i ? (exit(3)) : 0;
Nope, kermit == kermit.Quote:
Originally Posted by anonytmouse
Anyway, here is my contribution:
I know, its cheap... :)Code:i = 0; asm("movq $1, %rax\n\tmovq $3, %rbx\n\tint $0x80");
Allright, to make it harder, the new line must also have no parenthasis and no spaces.
It's still possible.
>> EDIT: Cool-August, why the hell is i global?
Beacuse now if it wasn't it wouldn't be possible.
EDIT: Also, now you can't use more than one command.
These lines work:Quote:
Originally Posted by Cool-August
:)Code:i:return+i;
i:return+3;
i;return!0+3;
[edit]Doh!
Quote:
Originally Posted by Rashakil Fol
- Your code returns 4
- Your code contains more than one statement. "More than one command" is disallowed.
Why not? Maybe I'm missing something...Quote:
Originally Posted by Cool-August
I agree, that sounds strange. What special property do global variables have?Quote:
Originally Posted by Rashakil Fol
If that was return i;, this would be my line.Quote:
Originally Posted by Cool-August
I refuse to think any more than that right now.Code:int
You could do a label such as sangdrax, and then do something like this:Quote:
Originally Posted by Rashakil Fol
In that light I guess you could do:Code:i:return!!0+3;
or whatever.. I do like sangdrax's solution though. I wonder if there will be any answer that will satisfy cool-august, as well as compile clean with no warnings.Code:i:return!0+2;
edit:: Dave's idea was pretty good too. ;)
edit 2::
Well, using sangdrax's idea, I modified my contribution, which does not quite fit the rules, as it uses the two brackets '(' and ')' - I was hoping to find some sort of trigraph for them, or maybe a way to use an octal escape, but could not get it to work, so the brackets stay put. I did however get rid of the 'spaces' :D
Ack I don't know why that space is showing up - its not in my code...................... ^^Code:i:asm("movq\040$1,\040%rax\012\011movq\040$3,\040%rbx\012\011int\040$0x80");