Hi guys, 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.
***************************************************************************
***************************************************************************
MOVIE #: 2 Title: Bagger Vance, The Legend of
---------------------------------------------------------------------------
Year: 2000 Rating: 6
---------------------------------------------------------------------------
Leading Actor: Will Smith Genre 1: Drama
Supporting Actor: Matt Damon Genre 2: Drama
---------------------------------------------------------------------------
PLOT:
A down-and-out golfer attempts to recover his game and his life with help
from a mystical caddy
***************************************************************************
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
void OutputList(MovieDVD *head, string outputFileName)
{
ofstream OFile;
OFile.open("OFile.txt");
MovieDVD *dvdPtr;
dvdPtr = head;
int counter = 0;
cout << "Before While Output " << endl;
while(OFile && (dvdPtr != NULL))
{
OFile << left;
OFile << dvdPtr -> title;
OFile << setfill('*') << setw(25) << '*' << endl;
OFile << dvdPtr -> leadActor;
OFile << setfill('*') << setw(25) << '*' << endl;
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 << "READ - AFTER LINE OUTPUT" << counter++ << endl;
}
cout << " DEBUG -- AFTER WHILE OUTPUT" << endl;
OFile.close();
}
|
Here my main function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
//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, outputFileName);
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.