char array not assignable

后端 未结 4 933
陌清茗
陌清茗 2020-12-19 17:26

Okay, so I want to save a word in a char array but it gives me a error

Here\'s my code

#include 
#include  
#i         


        
4条回答
  •  时光说笑
    2020-12-19 18:07

    see this is not only for character array , this implies for all type of arrays but the question aries why?,when we can assign other variable why not array the thing is:- suppose we have:

    int a[size];
    a = {2,3,4,5,6};
    

    because here the name of an array mean address of the first location of an array

    printf("%p",a); // let suppose the output is 0x7fff5fbff7f0
    

    We are saying by that

    0x7fff5fbff7f0 = something; which is not correct yes we can do a[0] = something , now it saying assign the value of array at 0th location.

提交回复
热议问题