Multidimensional String Array Assignment C++ -
i have preallocated multidimensional string array declared follows:
std::string test[5][169] = { { },{ },{ },{ },{ } };
i need make function accepts input string this:
{"abc","dac","fab" },{"hbv","acd" },{ "ccd","ahn","agt","atr"},{"are"},{ }
and puts correctly values in array(as i'm assigning it);
the problem can't pass 2d+ array parameter function in c++ , can't assignment multidimensional array this:
test= {"abc","dac","fab" },{"hbv","acd" },{ "ccd","ahn","agt","atr"},{"are"},{ };
i'm looking method put correctly values array.
i tried use std::vector
, solved problem 1 dimensional array:
std::vector<std::string> test; test = {"abc","dac","fab" };
but i'd need like
std::vector< std::vector<std::string> > test; test = {"abc","dac","fab" },{"hbv","acd" },{ "ccd","ahn","agt","atr"},{"are"},{ };
add additional pair of braces in last line , should done:
test = {{"abc","dac","fab" },{"hbv","acd" },{ "ccd","ahn","agt","atr"},{"are"},{ }};
Comments
Post a Comment