Array increment operator in C

前端 未结 7 538
暖寄归人
暖寄归人 2020-11-28 10:13

I don\'t understand the results of following code:

#include 
#include 
int main()
{
   int a[4]={1, 3, 5, 6};
   //suppose a is         


        
7条回答
  •  爱一瞬间的悲伤
    2020-11-28 10:56

    The name of array is a constant pointer and so it will always point to the 0th element of that array. It is not a variable so nor can we assign some other address to it neither can we move it by incrementing or decrementing. Hence

    a = &var;  /*Illegal*/
    a++;       /*Illegal*/
    a = a-1;   /*Illegal*/
    

提交回复
热议问题