Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > C++

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-07-2009, 11:21 AM
AdRock AdRock is offline
Registered User
 
Join Date: Jan 2007
Posts: 60
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;
}
Reply With Quote
  #2  
Old 11-08-2009, 01:36 PM
vijayan vijayan is offline
Registered User
 
Join Date: Dec 2007
Posts: 281
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;
}
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT -4. The time now is 07:54 PM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.