Click here to Skip to main content
14,699,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guy !
I want to create a vector of array
vector<BYTE[6]> cKey;
BYTE keyTemp[6];
memset(keyTemp, 0xFF, sizeof(keyTemp)); // Key is FFF...FF
cKey.push_back(keyTemp);


but, push_back function is show error
Error C3074: an array can only be initialized with an initializer-list


How to initialize a vector of array ?
Posted
Comments
Richard MacCutchan 20-Oct-15 3:20am
   
What are you trying to do with the vector?

Seems like it is not possible to initialize the array the way you are doing it.
See this link error C3074: an array can only be initialized with an initializer-list[^]

In your case it should be
std::vector<std::array xmlns:std="#unknown"><byte,>> cKey { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
</std::array>

or maybe
std::array<byte,> keyTemp { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
cKey.push_back(keyTemp);
   
Comments
Mạnh Lê 20-Oct-15 21:31pm
   
Thank alot,
Change normal array with std::array
vector<byte*> cKey; // Change here


BYTE keyTemp[6];
memset(keyTemp, 0xFF, sizeof(keyTemp)); // Key is FFF...FF
cKey.push_back(keyTemp);
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900