int main()
{
int ar[ 2 ] ;
ar++; // error !! ar is constant, it cannot be changed
ar+=2; // same error
int* p = ar;
// is the same as :
int* q = &ar[ 0 ];
// or
int* r = &ar;
p++; // okay! this will point to the 2nd element in ar
}
aW50IG1haW4oKQp7CglpbnQgYXJbIDIgXSA7CgkKCWFyKys7IC8vIGVycm9yICEhIGFyIGlzIGNvbnN0YW50LCBpdCBjYW5ub3QgYmUgY2hhbmdlZAoJYXIrPTI7IC8vIHNhbWUgZXJyb3IKCQoJaW50KiBwID0gYXI7CgkvLyBpcyB0aGUgc2FtZSBhcyA6CglpbnQqIHEgPSAmYXJbIDAgXTsKCS8vIG9yCglpbnQqIHIgPSAmYXI7CgkKCXArKzsgLy8gb2theSEgdGhpcyB3aWxsIHBvaW50IHRvIHRoZSAybmQgZWxlbWVudCBpbiBhciAKfQ==
prog.cpp: In function ‘int main()’:
prog.cpp:5:4: error: lvalue required as increment operand
ar++; // error !! ar is constant, it cannot be changed
^
prog.cpp:6:4: error: incompatible types in assignment of ‘int’ to ‘int [2]’
ar+=2; // same error
^
prog.cpp:12:12: error: cannot convert ‘int (*)[2]’ to ‘int*’ in initialization
int* r = &ar;
^
prog.cpp:10:7: warning: unused variable ‘q’ [-Wunused-variable]
int* q = &ar[ 0 ];
^
prog.cpp:12:7: warning: unused variable ‘r’ [-Wunused-variable]
int* r = &ar;
^