Array length problem

后端 未结 6 1570
栀梦
栀梦 2021-01-21 07:46

I was reading a csc placement paper where I read a question related to c language array\'s sizeof() operator. Answer was something else then i expected it to be.



        
6条回答
  •  粉色の甜心
    2021-01-21 08:29

    Because int array[] is just a pointer and it's size is same as of int. I think you expected that size of arr will somehow be passed to function, but it doesn't work that way. Size of arr can be determined only in same scope where it was declared, because sizeof actually works at compile time.

提交回复
热议问题