[ create a new paste ] login | about

Link: http://codepad.org/5CVGFYll    [ raw code | output | fork ]

C++, pasted on Jun 24:
#include <iostream>
#include <stdio.h>


int main()
{
    bool test = false; // == 0
    printf("value of test: <%d>\n", test);
    test++; // == 1
    printf("value of test: <%d>\n", test);
    test++; // == 1
    printf("value of test: <%d>\n", test);
    
    //but now with some magic
    void* pnt = &test;
    unsigned char& magic = *(unsigned char*)pnt;
    //magic now points to the same addres as test

    //here it gets strange...    
    magic = 137;
    printf("value of test: <%d> -- 137 wtf?!\n", test); //137 wtf?!
    magic++;
    printf("value of test: <%d>\n", test);

    return 0;
}


Output:
1
2
3
4
5
value of test: <0>
value of test: <1>
value of test: <1>
value of test: <137> -- 137 wtf?!
value of test: <138>


Create a new paste based on this one


Comments: