[英]c++ library for copying array contents to the pointer
int a[4]={1,2,3,4};
int* b = new int[4];
是否有類似std :: copy的庫函數將數組a中的元素復制到c ++中的指針b?
是的,它叫做std::vector<>
; 您將在代碼中使用它,如下所示:
std::vector<int> a { 1, 2, 3, 4 };
auto b = a;
是否有類似std :: copy的庫函數將數組a中的元素復制到c ++中的指針b?
是的,那是std::copy
:
std::copy( std::begin( a ), std::end( a ), b );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.