title: Write content of LinkedList in a txt file.
body: <p>So I have the following code in which I print out the content of linked list, however I'm trying to write it in a file. I successfully read off a file and created the linkedlist but now I'm stuck in how to write it back into another file. </p>
  
  <pre><code>void LinkedList::printAll()
  {
      if(p==NULL)
      {
          cout&lt;&lt;"There are no nodes in the list"&lt;&lt;endl;
          return;
      }
      else
      {
          Node *tmp = p;
          cout&lt;&lt;endl&lt;&lt; "RUID    Name"&lt;&lt;endl;
  
          while(tmp!=NULL)
          {
              cout &lt;&lt;tmp-&gt;ID &lt;&lt;"\t"&lt;&lt;tmp-&gt;name&lt;&lt;endl;
              tmp=tmp-&gt;next;
          }
      }
      cout&lt;&lt;endl;
  }
  </code></pre>
  
  <p>This is what I'm trying to write in a file instead of printing out. Any help would be wonderful. </p>
  
  <p>This is what it should look like</p>
  
  <p>RUID Name
  4325 Omar
  5432 Partha
  6530 Rani
  1034 Esha
  2309 Rana
  3214 Badri</p>