Last active
August 29, 2015 14:02
-
-
Save anandology/cdbb843b16404260e0b0 to your computer and use it in GitHub Desktop.
C program that prints 2+2=5. http://codegolf.stackexchange.com/questions/28786/write-a-program-that-makes-2-2-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void hack() { | |
int start = 0; | |
int *p=&start; | |
/* start moving up the stack until we find the marker. */ | |
while (*p != 0x12345678) | |
p++; | |
/* set x to 3 */ | |
p[-1] = 3; | |
} | |
int main() { | |
int marker = 0x12345678; | |
int x = 2; | |
int y = 2; | |
hack(); | |
printf("%d\n", x+y); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment