Array Assignment

前端 未结 3 1406
心在旅途
心在旅途 2020-12-19 14:47

Let me explain with an example -

#include 

void foo( int a[2], int b[2] ) // I understand that, compiler doesn\'t bother about the
                  


        
3条回答
  •  执笔经年
    2020-12-19 15:05

    You answered your own question.

    Because these

    int a[] = { 1,2 };
    int b[] = { 3,4 };
    

    have type of int[2]. But these

    void foo( int a[2], int b[2] )
    

    have type of int*.

    You can copy pointers but cannot copy arrays.

提交回复
热议问题