I'd like to know how I can assign the value of a vector<string> to another vector.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
vector<vector<Client>> vvc;
vector<Client> vc;
vector<string> vs;
int j = 0;
for (int i = 0; i < vs.size() / 4; i++)
{
vc[i].fullName = vs[j];
vc[i].idcardNo = vs[j + 1];
string s = vs[j + 2];
vc[i].accountNumber = (float)atof(s.c_str());
string d = vs[j + 3];
vc[i].balance = (float)atof(d.c_str());
vvc.push_back(vc);
j = j + 4;
}
I am getting the error that a vector is out of range on the bold line. I checked via debugging that vs[j] has a value of "John Doe", so the error must be from the vc[i].fullName .... can anyone point me towards a solution please?
cire .... I got your reasoning. The vvc makes sense, what doesn't make sense is the vector<client> ... hah that should not be a vector but an object of type client .... what the .. was i thinking !!