Hi everyone trying to translate an older C program that uses array of structures into C++ program that uses linked lists. I'm a total C++ newb and I'm a little confused on the syntax of setting up a linked list in C++.... here's my code:
#include <iostream>
#include <stdlib.h>
#include <string>
#include <ctype.h>
#include <fstream>
using namespace std;
struct Video {
char video_name[1024];
int ranking; // Number of viewer hits
char url[1024]; // Video URL
struct Video *next; // pointer to Video structure
}
struct Video* Collection = new struct Video;
Collection *head = NULL; // EMPTY linked list
In my old program Collection
was an array of Video
. How can I make Collection
be a linkedlist of Video
nodes? I am currently getting errors saying on the last two lines code saying: expected initializer before 'Collection'
and expected constructor, destructor or type conversion before '*' conversion
. I know my syntax is definately wrong, but I guess I dont understand how to create a linked list of Videos inside of Collection...