[ create a new paste ] login | about

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

C++, pasted on Jul 12:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
 
const int a = 5;

int main(int argc, char *argv[])
{
    std::cout << "Hello!" << std::endl;
    int *b;
    b = const_cast<int *>(&a);
    *b = 4;
    std::cout << &a << " " << b << std::endl;
    std::cout << a << " " << *b << std::endl;
}


Output:
1
2
3
Hello!

Segmentation fault


Create a new paste based on this one


Comments: