C++:vector assign
程序员文章站
2022-03-01 23:21:27
...
#include <iostream>
#include <vector>
#include <stdint.h>
using namespace std;
int main()
{
vector<uint8_t> data;
uint8_t arr[10] = {1, 2, 3, 4, 5};
data.assign(arr, arr + 10);
cout << "vector size: " << data.size() << endl;
return 0;
}
[email protected]:~/demo$ ./a.out
vector size: 10