I have a string which i then want to store in a vector
string a = "N\nT\n";
after each new line to be in a different cell.
std::string ss (".V/\n.F/\n.R/\n");
for(int i = 0; i< ss.size(); i++)
{
test1.push_back(ss);
}
I want to store the string in vector test1
is this the best way?
Your code won’t work; it’ll store the string
ss.size()times in the vector.You might want to use a string stream to split the string:
Note that the newline character will be discarded. If you want to keep it,
push_back(line + "\n");.