Hi
I've created a program for my final project entitled 'Video Rental System'. I used linked list and the output is saved into an external file (*.txt). Some of the functions are Add New Video, Delete Video, Display List of Videos etc.
The problem is, whenever the display function is called, it will only display one word only. But in the *.txt file it is a full word. For example, if i key in 'Lord of The Rings' for video's title, it will only be 'Lord' when display function is called. But in *.txt file, it is 'Lord of The Rings'. Should i use string? Need some help pls
Code:
***** Add new video function *****
void List::AddVideo() // method add video dlm linked list
{
int code;
char category[20];
char title[40];
Node *newNode = new Node;
cout<<" Enter video's code : ";
cin>>code;
newNode->Code=code;
cout<<" Enter video's category : ";
cin.ignore();
cin.getline(category,20,'\n');
// cin>>category;
strcpy(newNode->Category,category);
cout<<" Enter video's title : ";
cin.getline(title,40,'\n');
// cin>>title;
strcpy(newNode->Title,title);
cout<<" \n New video has been added";
newNode->link=head;
head=newNode;
if (no_of_node == 0)
tail = newNode;
no_of_node++;
ofstream OutputFile("Record.txt",ios::app); // output data dlm "Record.txt"
Node *current = head;
OutputFile<<current->Code<<setw(22)<<current->Category<<setw(21)<<current->Title;
OutputFile<<endl;
}
***** Display function *****
void List::Display() //method display list
{
char pause;
Node *current = head;
cout<<" CODE"<<setw(17)<<" CATEGORY"<<setw(17)<<" TITLE\n"<<endl;
while (current !=0)
{
cout<<" "<<current->Code<<setw(17)<<current->Category<<setw(17)<<current->Title<<endl;
current = current->link;
}
cout<<"\n";
}