title: Read from text file and make a dictionary text file
body: <p>I want to read a text file and store new words in linked list. From this linked list I want to write a dictionary file with new words. I don't know why my code don't run. Can anyone help me?</p>
  
  <p>p/s: when i run debug it found this when store vector element to new_node->word
  <a href="https://i.stack.imgur.com/cXSGz.png" rel="nofollow noreferrer">Error</a>
  This is my code</p>
  
  <hr>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;fstream&gt;
  #include &lt;sstream&gt;
  #include &lt;cstring&gt;
  
  using namespace std;
  typedef struct dictionary
  {   string word;
      int line;
      int page;
      struct dictionary* next;
  } node;
  
  
  int main()
  {
      node* Head = NULL;
      ifstream file("filetest.txt");
      if(file.fail())
          cout &lt;&lt; "Loi mo file! "&lt;&lt;endl;
      string temp;
      int cpage = 1,cline = 1;
      while(getline(file,temp))
      {
          stringstream spliter;
          spliter &lt;&lt; temp;
          vector&lt;string&gt; result;
          while(!spliter.eof())
          {
              string str;
              spliter &gt;&gt; str;
              result.push_back(str);
          }
          for(size_t i = 0;i != result.size();i++)
          {
              if(Find(Head,result[i])==0)
              {
                  Append(&amp;Head,result[i],cline,cpage);
              }
  
          }
          cline++;
          if(cline == 25)
              cpage++;
  
      }
      file.close();
      ;
      ofstream outfile("test.txt");
      node* p = Head;
      while(p != NULL)
      {
          outfile &lt;&lt; p-&gt;word &lt;&lt;","&lt;&lt;p-&gt;page&lt;&lt;"-"&lt;&lt;p-&gt;line&lt;&lt;endl;
          p=p-&gt;next;
      }
  
  
  }
  </code></pre>
  
  <p>Append( add member to linked list)</p>
  
  <pre><code>void Append(node** First,string &amp;newstr,int newl,int newp)
  {
      node* new_node = (node*)malloc(sizeof(node));
      node* last = *First;
      new_node-&gt;word=newstr;
      new_node-&gt;line=newl;
      new_node-&gt;page=newp;
      new_node-&gt;next = 0;
      if(*First == 0)
      {
          *First = new_node;
          return;
      }
      while(last-&gt;next != 0)
      {
          last = last-&gt;next;
      }
      last-&gt;next = new_node;
      return;
  }
  </code></pre>
  
  <p>Find( check if a word is new or not)</p>
  
  <pre><code>int Find(node* head,string &amp;tumoi)
  {
      node* current = head;
      while(current != 0)
      {
          if(current-&gt;word == tumoi)
              return 1;
          current = current-&gt;next;
      }
      return 0;
  }
  </code></pre>