Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3853866
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:32:08+00:00 2026-05-19T17:32:08+00:00

I have a vector like this: std::vector<std::vector<char> > _lines; I would like to iterate

  • 0

I have a vector like this:

std::vector<std::vector<char> > _lines;

I would like to iterate these vector and the vector contained within, however I’m not sure how I’d access the inside vector using the iterator of the first one?

I have the following already:

std::vector<std::vector<char> >::iterator first_iter = _lines.begin();

        for (; first_iter != _lines.end(); first_iter++)
        {
            (*first_iter)::iterator second_iter = (*first_iter)->begin();  // something is wrong with this? How do I get the second vector to iterate?
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:32:08+00:00Added an answer on May 19, 2026 at 5:32 pm
    for (std::vector<std::vector<char> >::iterator i = _lines.begin();
                                                   i != _lines.end(); ++i)
    {
        for (std::vector<char>::iterator j = i->begin(); j != i->end(); ++j)
        {
            // ... use *j
        }
    }
    

    If you use a modern compiler, you can use the C++0x feature auto to deduce the type automatically:

    for (auto i = _lines.begin(); i != _lines.end(); ++i)
    {
        for (auto j = i->begin(); j != i->end(); ++j)
        {
            // ... use *j
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a map like this: std::map<char, std::vector<char> > m; m['A'].push_back('a'); m['A'].push_back('b'); m['A'].push_back('c');
I have declared std::priority_queue like this. priority_queue < Aircraft, vector<Aircraft>, less<Aircraft> > *q; And
I have a class that looks like this: typedef std::list<char*> PtrList; class Foo {
I have a std::vector of bytes ( char ), I'd like to do the
I have a vector in R that looks like this: dat <- c(TRUE, TRUE,
I have a vector, v3, that looks like this: v3 <- matrix(c(1,1,3,3,2,2, 2,3,1,2,3,1, 3,2,2,1,1,3),
I have a large nested vector that look like this: import Data.Vector let x
Assuming I have a function like this my_method(const vector<const T*> & param); I wonder
I have a vector of pairs representing hops between nodes which I would like
I have a weird problem. I have a vector that I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.