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

  • Home
  • SEARCH
  • 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 8025019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:01:56+00:00 2026-06-04T23:01:56+00:00

I am getting a List Iterator Not incrementable on the code below after adding

  • 0

I am getting a List Iterator Not incrementable on the code below after adding a stringstream for movieName and am unsure as how to go about solving the error. I am trying to read in from a file and add the items into a list then itterate through the list and add eash word from the title of the movie into another list. Any help would be appreciated!

#include <iostream>
#include <string>
#include <list>
#include <fstream>
#include <sstream>

using namespace std;

int main()
{
list <string> movieList;
list <string>::iterator iterMovie; 

list <string> *titleWordList = new list <string>;
list <string>::iterator iterTitleWord; 

ifstream inFile;
inFile.open("JamesBond.txt"); 

if (!inFile)
{
    cout << "Could not find the specified file.";
}
else 
{
    movieList.clear();
    string movieName;

    while(getline(inFile,movieName))
    {
        movieList.push_back((movieName));

        /*
        for each(string movieName in movieList)
        {
            titleWordList->push_back(movieName); 
        }
        */

        stringstream ss(movieName);
        while (ss >> movieName)
        {
             titleWordList->push_back(movieName); 
        }

    }
}

if (movieList.empty())
{
    cout << "No Data Found!" << endl; 
}
else
{
    cout << "Writing Output: \n\n";

    for (iterMovie=movieList.begin(); iterMovie !=movieList.end(); ++iterMovie)
    {
        cout << *iterMovie << endl; 

    }

    for (iterTitleWord=movieList.begin(); iterTitleWord != movieList.end();     ++iterMovie)
    {
        cout << *iterTitleWord << endl;
        cout << &titleWordList; 
    }


  }
}
  • 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-06-04T23:01:57+00:00Added an answer on June 4, 2026 at 11:01 pm

    In the second for there is a copy paste error, it should be ++iterTitleWord instead of ++iterMovie.

    Also, as @Greg suggested, iterTitleWord=movieList.begin() and iterTitleWord != movieList.end() should be iterTitleWord=titleWordList->begin() and iterTitleWord != titleWordList->end() respectively.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im getting the following error for the piece of code below : expression list
I keep getting a 'List does not exist' error whenever I try and use
I have the code below for getting a list of child processes on windows
Im getting the following error when attempting to build a list of 'interests' check
I am having trouble getting the correct sorted list. I am not sure what
I hope this is not painfully obvious. I am getting this cryptic error :
I am getting an error with Hibernate (I am not too familiar the API
I am working on a piece of code with Iterator and getting a ConcurrentModificationException
I think I know why I am getting this error, but I'm not sure
I keep on getting this error Exception in thread main org.hibernate.LazyInitializationException: could not initialize

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.