title: Reading multiple data types in a file and storing it in a linked list C++
body: <p>how can you read multiple data types in a file and storing it in a linked list. I have the code shown below but it normally reads the file with no linked list but when I used linked list it doesn't work. I think there is something wrong in my code. Programming language: C++ Hope you can help me on how to do this. Thank you</p>
  <pre><code>struct Video {
  int videoID;
  string movieTitle;
  string movieGenre;
  string movieProduction;
  int numberOfCopies;};
  
  class videoList {
  private:
      struct videoNode {
          Video video;
          struct videoNode *next;
      };
      videoNode *head;
  
  public:
      videoList(); //constructor
      //~videoList(); //deconstructor
      void insertNewVideo (Video vid);
      void rentVideo (Video vid);
      void returnVideo (Video vid);
      void showVideoDetails (Video vid);
      void displayVideo ();
      bool isVideoExist();
      void exit ();
      void generateVideoID();
      void readVideoFile();};
  
  void videoList::readVideoFile () {
  videoNode *nodePtr;
  ifstream file( &quot;videoList.txt&quot; ) ;
  string line ;
  string id, movieTitle, movieGenre, movieProduction, numberOfCopies;
  
  if (!file) {
      cout &lt;&lt; endl &lt;&lt; &quot;\t\t\t\t There is file!&quot; &lt;&lt; endl;
  }
  else {
      std::stringstream linestream(line);
      cout &lt;&lt; endl &lt;&lt; &quot;\t\t\t\t Movie List &quot; &lt;&lt; endl; 
      nodePtr = head;
  
      while (nodePtr)
          while (getline(file, line)){
  {
  
  
      std::getline(linestream, id, ',');
      std::getline(linestream, nodePtr-&gt;video.movieTitle, ',');
      std::getline(linestream, nodePtr-&gt;video.movieGenre, ',');
      std::getline(linestream, nodePtr-&gt;video.movieProduction, ',');
      linestream &gt;&gt; nodePtr-&gt;video.numberOfCopies;
  
      if(linestream) // true if there were no errors reading the stream
      {
          std::cout &lt;&lt; id &lt;&lt; '\n';
          std::cout &lt;&lt; nodePtr-&gt;video.movieTitle &lt;&lt; '\n';
          std::cout &lt;&lt; nodePtr-&gt;video.movieGenre &lt;&lt; '\n';
          std::cout &lt;&lt; nodePtr-&gt;video.movieProduction &lt;&lt; '\n';
          std::cout &lt;&lt; nodePtr-&gt;video.movieTitle &lt;&lt; '\n';
      }
  }}}}
  </code></pre>