Assign array to array

后端 未结 6 1015
礼貌的吻别
礼貌的吻别 2021-01-03 23:32

So I am playing around with some arrays, and I cannot figure out why this won\'t work.

int numbers[5] = {1, 2, 3};
int values[5] = {0, 0, 0, 0, 0};
values =          


        
6条回答
  •  一生所求
    2021-01-04 00:02

    std::array is a good idea, but this is also possible:

    struct arr { int values[5]; };
    
    struct arr a{{1, 2, 3}};
    struct arr b{{}};
    
    a = b;
    

    Otherwise, use std::memcpy or std::copy.

提交回复
热议问题