fork(3) download
  1. int main()
  2. {
  3. int ar[ 2 ] ;
  4.  
  5. ar++; // error !! ar is constant, it cannot be changed
  6. ar+=2; // same error
  7.  
  8. int* p = ar;
  9. // is the same as :
  10. int* q = &ar[ 0 ];
  11. // or
  12. int* r = &ar;
  13.  
  14. p++; // okay! this will point to the 2nd element in ar
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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;
       ^
stdout
Standard output is empty