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 8839351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:13:14+00:00 2026-06-14T10:13:14+00:00

Im trying to write a program that allow a user to track their DVDs.

  • 0

I”m trying to write a program that allow a user to track their DVDs. Use an input file which include these attribute for each movies.

Basically, the user should be able to enter in the name of input file.
Using a structs and pointers, created a linked list of the movies in the input file.
Next, output the linked list to an output file.
Format the output of the plot such that it will word wrap.

The output suppose to look like this

***************************************************************************
MOVIE #: 1 Title: Antwone Fisher
---------------------------------------------------------------------------
Year: 2002 Rating: 7
---------------------------------------------------------------------------
Leading Actor: Denzel Washington Genre 1: Biography
Supporting Actor: Derek Luke Genre 2: Drama
---------------------------------------------------------------------------
PLOT: 
Antwone Fisher, a young navy man, is forced to see a psychiatrist after a 
violent outburst against a fellow crewman. During the course of treatment 
a painful past is revealed and a new hope begins.
***************************************************************************

So far, the problem is my output and I can’t display the output. I try to debug it and it turn out that I’m stuck on the while loop.

Here’s my output function

 void OutputList(MovieDVD *head)
{
    ofstream OFile;
    OFile.open("OFile.txt");

    MovieDVD *dvdPtr;
    dvdPtr = head;


    cout << "Before While Output " << endl;

    while(dvdPtr != NULL)
    {
        OFile << left;
        OFile << dvdPtr -> title;

        OFile << dvdPtr -> leadActor;

        OFile << dvdPtr -> supportActor;
        OFile << setfill('*') << setw(25) << '*' << endl;
        OFile << dvdPtr -> genre;
        OFile << setfill('*') << setw(25) << '*' << endl;
        OFile << dvdPtr -> altGenre;
        OFile << setfill('*') << setw(25) << '*' << endl;
        OFile << dvdPtr -> year;
        OFile << setfill('*') << setw(25) << '*' << endl;
        OFile << dvdPtr -> rating;
        OFile << setfill('*') << setw(25) << '*' << endl;
        OFile << dvdPtr -> synopsis;
        OFile << setfill('*') << setw(25) << '*' << endl;

        dvdPtr = dvdPtr -> next;
        cout << endl;

        cout << "READ - AFTER LINE OUTPUT" << endl;
    }
    cout << " DEBUG -- AFTER WHILE OUTPUT" << endl;

    delete dvdPtr;
    dvdPtr = NULL;
    OFile.close();
}


Here my main function:

    //INPUT OUTPUT FILE DECLARATION
    ifstream inFile;                    //INPUT FILE declaration
    ofstream OFile;                     //OUTPUT FILE declaration

    //VARIABLE DECLARATION
    string inputFileName;               //IN  - Input file name
    string outputFileName;              //OUT - Output file name
    string synopsis;
    MovieDVD *head;
    MovieDVD theMovie;



    head = NULL;

    //INPUT
    cout << "What input file would you like to use?: ";
    getline(cin, inputFileName);
    cout << "DEBUG -- BEFORE CREATELIST "<< endl;

    CreateList(head, inputFileName);
    cout << "DEBUG -- AFTER CREAETLIST " << endl;

    //OUTPUT LIST
    cout << "What output file would you like to use?: ";
    getline(cin, outputFileName);


    OutputList(head);
    WordWrap(OFile, head, synopsis);

I add the cout for my debug on output list and only
cout << "Before While Output " << endl and cout << " DEBUG -- AFTER WHILE OUTPUT" << endl come out and skip the while loop. Help me please.

My Creative List Function

void CreateList(MovieDVD *head, string inputFileName)
{
    ifstream inFile;
    inFile.open("inFile.txt");

    MovieDVD *dvdPtr;

    head = NULL;
    dvdPtr = NULL;
    dvdPtr = new MovieDVD;

    int counter =0;

    cout << " DEBUG -- BEFORE WHILE" << endl;
    while (inFile && (dvdPtr != NULL))
    {
        getline(inFile, dvdPtr -> title);

        getline(inFile, dvdPtr -> leadActor);

        getline(inFile, dvdPtr -> supportActor);


        getline(inFile, dvdPtr -> genre);

        getline(inFile, dvdPtr -> altGenre);

        inFile >> dvdPtr -> year;

        inFile >> dvdPtr -> rating;
        inFile.ignore(1000, '\n');

        getline(inFile, dvdPtr -> synopsis);

        dvdPtr -> next = head;
        head = dvdPtr;
        dvdPtr = new MovieDVD;

        cout << "READ line " << counter++ << endl;
    }
cout << " DEBUG -- AFTER WHILE" << endl;

    delete dvdPtr;
    dvdPtr = NULL;
    inFile.close();

}

  • 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-14T10:13:15+00:00Added an answer on June 14, 2026 at 10:13 am

    You are not creating the list in your CreateList function. Well, you are, but not in a way you would like to. See, your list is being created, and the pointer dvdPtr points to it. So far, so good. But then you do this:

    head = dvdPtr;
    

    You assume that after the function exits, the head pointer would hold the list, but it’s wrong. In this line you are changing a local pointer, so once the function exits, you lose it. That’s probably the reason why your output skips the while loop – the list is just empty. You need to pass a reference to your pointer:

    void CreateList(MovieDVD *&head, string inputFileName)
    

    then it will allow you to change it the way you want.

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

Sidebar

Related Questions

I'm trying to write something that will allow a user to use a keyboard/mouse
I was trying to write a TextQuery program that allow user: 1. inputs a
I'm trying to write a program that takes a large file (of any type)
I'm trying to write a program that could monitor multiple folders for file creations
I am trying to write a program which will allow two players to play
I am trying to write a program that allows a binary to be run,
I'm trying to write a program that would convert celcius to fahrenheit and visa-versa.
I am trying to write a program that will prompt you to enter someone's
I am trying to write a program that sends basic text files from one
I am trying to write a program that displays the integers between 1 and

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.