Assign array to array

后端 未结 6 1072
礼貌的吻别
礼貌的吻别 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:22

    You can't assign arrays in C++, it's stupid but it's true. You have to copy the array elements one by one. Or you could use a built in function like memcpy or std::copy.

    Or you could give up on arrays, and use std::vector instead. They can be assigned.

提交回复
热议问题