I manage to insert values into range vector, but in range vector I have data RangeA, RangeB, RangeC..
Using this data, I want to create a vector for this range under block vector, how am I supposed to go with it?
vector <string> range;
for(int i=0;i<range.size();i++)
{
cout<<"range: "<<range[i]<<endl;
vector <string> block[i]; <<<<<<<
}
Output:
range: RangeA
range: RangeB
range: RangeC
Thanks in advance!
vector <string> range;
for(int i=0;i<range.size();i++)
{
cout<<"range: "<<range[i]<<endl;
// create a vector of size i
// with each element of default
// value "default"
vector <string> block(i,string("default"));
}
vector<string> range;
//Create block vector with size
//same as range vector
vector <string> block(range.size());
//Now you can iterate range vector
//and initialize the block vector with value
for (int i = 0 ; i < range.size(); i++)
{
block[i]=string(range[i]);
}
for (int i = 0 ; i < block.size(); i++)
{
cout<<block[i];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.