268 views
0 votes
0 votes
Can  i access array like this:

const int array [5]= {10,20,30,40,50};

int *x;

x=array+5;

*x=6;   // can  i assign  this value as x is pointing to some unknown location. and other array is constant.

x=array+2;

*x=2; // can i assign  if array is constant.

 

in both assignment any compiler error would be  there ????

Please log in or register to answer this question.

Related questions

0 votes
0 votes
0 answers
1
Hira Thakur asked Nov 18, 2017
351 views
The output of below code is_______________. int main() { int i = 120; int *a = &i; foo(&a); printf("%d ", *a); printf("%d ", *a); } void foo(int const a) { int j = 210; ...
3 votes
3 votes
1 answer
2
Hira Thakur asked Jun 14, 2017
757 views
The output of below code is_______________. int main() { int i = 120; int *a = &i; foo(&a); printf("%d ", *a); printf("%d ", *a); } void foo(int const a) { int j = 210; ...
2 votes
2 votes
3 answers
3