Click here to Skip to main content
15,887,371 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
C++
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
C++
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
C++
std::vector<std::array xmlns:std="#unknown"><byte,>> cKey { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
</std::array>

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


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

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