|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Getting string out of a 2D vector into a string variable
I have a 2D vector and I need to assign each value of the inner vector to a string.
I am having problems getting what is in the vector into a string variable If anyone could please help I would be very happy as I can't fix this problem Code:
for ( vector< vector< string > > :: size_type i = 0, size = info.size(); i < size; ++i)
{
for ( vector < string > :: size_type j = 0, length = info[i].size(); j < length; ++j)
{
//check to see if the inner vectors are empty
if(info[i].size() > 1)
//std::string strd = info[i][j].at(j);
//cout<<strd.c_str()<<endl;
//if(strd == "int") {cout << "INT: ";}
cout << info[i][j] << endl;
}
cout << endl;
}
|
|
#2
|
|||
|
|||
|
Code:
for ( vector< vector< string > > :: size_type i = 0, size = info.size(); i < size; ++i)
{
for ( vector < string >:: size_type j = 0, length = info[i].size(); j < length; ++j)
{
string strd = info[i][j] ; // this will do
// equivalent to
// vector< string >& inner_vec = info[i] ;
// string strd = inner_vec[j] ;
cout << strd << endl;
}
cout << endl;
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| multiprocessing or multithreading?? and how to do that.. | jinDoankz | VB Classic | 10 | 10-17-2007 04:37 PM |
| string array in c++ | emeric | C++ | 11 | 07-16-2007 10:36 PM |
| Create a vCard | admol | .NET | 0 | 02-27-2007 11:30 AM |
| Writing in HKEY_LOCAL_MACHINE...Access is denied | Martin | VB Classic | 22 | 12-03-2001 04:53 AM |
| Need Help debugging errors form these programs number1! | Fred Mayes | Java | 1 | 06-05-2001 07:12 AM |