int main() { int i = 42; int const *foo, *bar; foo = &i; bar = &i; *foo = 1; // error *bar = 2; // error }
Standard input is empty
prog.cpp: In function ‘int main()’:
prog.cpp:7:10: error: assignment of read-only location ‘* foo’
*foo = 1; // error
^
prog.cpp:8:10: error: assignment of read-only location ‘* bar’
*bar = 2; // error
^
Standard output is empty