Linked List - being outputed wrong. thank you for the help in advance!

#include "function.h"


Movie* ReadIn(){

// struct Movie{

// string title;
// string leadActor;
// string suppActor;
// string genre;
// string altGenre;
// int year;
// int rating;
// string synopsis;

// Movie* next;
//};

ifstream inFile;
inFile.open("inFile.txt"); // open file

Movie* head; // set pointers
Movie* temp;

head = NULL; // set to NULL
temp = NULL;

temp = new Movie; // start new node

while( inFile && temp != NULL)
{
getline(inFile, temp -> title ); // info from in-file
getline(inFile, temp -> leadActor) ;
getline(inFile, temp -> suppActor);
getline(inFile, temp -> genre);
getline(inFile, temp -> altGenre);
inFile >> temp -> year;
inFile.ignore(1000 , '\n');
inFile >> temp -> rating;
inFile.ignore(1000 , '\n');
getline(inFile, temp -> synopsis);
inFile.ignore(1000 , '\n');
inFile.ignore(1000 , '\n');

temp -> next = head; // points to hed
head = temp; // points to temp


temp = new Movie; // start new node
}

delete temp; // delete node
temp = NULL; // prevent memory leak

inFile.close(); // close file

return head; // return head or linked list
}
What output are you expecting?

What output are you getting?

EDIT:

I don't see any output in this function. What exactly is the problem?
Last edited on
I apologize I had my read in file correct its just when I outputed the function with headi forgot at the end of the out put to Ptr = Ptr->next
Topic archived. No new replies allowed.