M
M
Michael2016-01-07 21:23:16
C++ / C#
Michael, 2016-01-07 21:23:16

How to convert from vector< vector > arr to String^?

In general, I encountered the need to convert data from (for example)

vector< vector<string> > arr;
arr[1][3] = "asd";

to a regular String^ and back.
How can I do that?
Thank you in advance!
PS I didn’t work with vectors before, but today it is urgent to do the work (the program that generates a certain database in the form of a text file, I decided to make tables in the form of two-dimensional arrays, and since the number of rows in the table is unknown, this is a vector of vectors suddenly someone has more adequate options - offer, I will be sincerely grateful)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2016-01-07
@petermzg

std::stringstream ss;
for(size_t i = 0; i < arr.size(); ++i)
{
   vector<string>& vs = arr[i];
   for(size_t j = 0; j < vs.size(); ++j)
      ss << vs[j];
}
std::string s = ss.str();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question