I'm new in C programming and currently learning about array and strings. I'm quite confuse in this topic. Coming to my question-
- Since an array (for ex-
a[]={20,44,4,8}), the name in an expression decays into pointer constant,so whenever if i try to do pointer arithmetic for example-a=a+1or anything like this the compiler shows error but when the same thing I write in printf() function it is showing the address of the first element rather than showing error. Why? - In an expression for example
*(a+1)=2first(a+1)will be evaluated and then*will dereference it. My question is that ifais a pointer constant then how it can point to any other memory location in an array and how this expression is perfectly legal?
I tried to search about this but couldn't get the accurate result.