title: Write to text file from array list c++
body: <p>I have a file with 10 integers. I read the file and put it into a list. I then modify the list (add, delete, etc) and now I want to be able to save that list. So I have no idea how to take the items from my array list and save it into the file.</p>
  
  <p>1) Read the file and put it into list:</p>
  
  <pre><code>ifstream intFile, floatFile;
  ofstream intFileOut, floatFileOut;
  
  SortedList&lt;int&gt; intList;
  SortedList&lt;float&gt; floatList;
  int a=0;
  float b=0;
  
  intFile.open("int.dat");                            
  floatFile.open("float.dat");    
  
  while(intFile&gt;&gt;a)
  {
      intList.InsertItem(a);
      a++;
  }
  
  while(floatFile &gt;&gt;b)
  {
      floatList.InsertItem(b);
      b++;
  }
  
  intFile.close();    
  floatFile.close();
  </code></pre>
  
  <p>2) Modified the list</p>
  
  <pre><code>cout&lt;&lt;"------------------------------"&lt;&lt;endl;
  cout&lt;&lt;"INT LIST: "&lt;&lt;endl;
  cout&lt;&lt;"Adding 1 to list..."&lt;&lt;endl;
  intList.InsertItem(1);
  cout&lt;&lt;"Adding 2 to list..."&lt;&lt;endl;
  intList.InsertItem(2);
  cout&lt;&lt;"Deleting int 20 from the list..."&lt;&lt;endl;
  intList.DeleteItem(20);
  cout&lt;&lt;"------------------------------"&lt;&lt;endl;
  cout&lt;&lt;"INTs in the list: "&lt;&lt;endl;
  intList.GetNextItem(a);
  cout&lt;&lt;"------------------------------"&lt;&lt;endl;
  cout&lt;&lt;"Retriving int 30..."&lt;&lt;endl;
  cout&lt;&lt;"Position of int 30: ";intList.RetrieveItem(30);cout&lt;&lt;endl;
  </code></pre>
  
  <p>3) Now I want to take the intList and save it to intFileOut, if that makes sense?</p>
  
  <p>Any tips/help would be appreciated.</p>