title: C++ reading from file into linked list giving EXC_BAD_ACCESS
body: <p>hi guys im trying to transfer an older code from C to C++ for an assignment.... i have to implement a linked list by hand so I cannot use STL containers otherwise i'd already be done with this....</p>
  
  <p>here's my linked list:</p>
  
  <pre><code>#include &lt;iostream&gt; 
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  
  struct Video { 
  char video_name[1024];      //  video name
  int ranking;                // Number of viewer hits
  char url[1024];             //  URL
  Video *next;  // pointer to Video structure
  }  *head = NULL;        // EMPTY linked list
  </code></pre>
  
  <p>here is the read-in code:</p>
  
  <pre><code>void load()
  {
  struct Video *temp;
  temp = (Video*)malloc(sizeof(Video)); //allocate space for node 
  temp = head;
  ifstream myfile ("Ranking.dbm");
  if (myfile.is_open())
  {
      string line;
      while ( myfile.good() )
      {
  
          myfile.getline(temp-&gt;video_name,1024);
          myfile &gt;&gt; temp-&gt;ranking;
          getline(myfile, line); // need to skip 'ranking's
                                  // unread new-line
          myfile.getline(temp-&gt;url,1024);
          temp = temp-&gt;next; 
  
      }
      head = NULL;
      myfile.close();
  }
  
  else cout &lt;&lt; "Unable to open file"; 
  
  return ;
  
  }
  </code></pre>
  
  <p>it is reading from a text file <code>Ranking.dbm</code> which looks like this:</p>
  
  <pre><code>bagheera
  20
  bagheera.com
  sushi
  60
  sushi.com
  wicket
  99
  wicket.com
  teek
  100
  teek.com
  </code></pre>
  
  <p>basically each set of 3 lines should load into a <code>Video</code> structure which will be a new node in the linked list.</p>
  
  <p>due to circustances beyond my control i am using XCode for this project. my question is why am I getting this error. I thought EXC_BAD_ACCESS was primarily an Objective-C error...?</p>