title: One input to multiple output files C++
body: <p>I'm wondering if anyone has any idea on how to take input from one file (.txt) and output it into multiple output files (.txt). For example if it read 3 integer values, it would output the first value to the first output file and so on. I'm curious just to see if I can save myself some time by not having to run an output function three different times. </p>
  
  <p>Here's the code I've put together if anyone is interested to see further what I mean.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;fstream&gt;
  #include&lt;string&gt;
  #include&lt;array&gt;
  using namespace std;
  
  int main()
  {
  ifstream instream;
  ofstream outstream;
  int ip;
  string ipadd;
  string name;
  string date;
  char test1;
  
  instream.open("inputfile.txt");
  outstream.open("ipaddress.csv");
  outstream.open("name.csv");
  outstream.open("date.csv");
  
  
  
  if(instream.fail())
      cout&lt;&lt;"Incorrect File Name\n";
  
  
  while(!instream.eof())
      {
                   instream&gt;&gt;ip;
                   if(ip==192)
                   {
                         instream.ignore(10000,'\n');
                   }
                   else
                   {
                   instream&gt;&gt;ipadd;
                   instream.ignore(3, ' - ');
                   instream&gt;&gt;name;
                   instream.ignore(2, '[');
                   instream&gt;&gt;date;
                   cout&lt;&lt;ip&lt;&lt;ipadd&lt;&lt;"   "&lt;&lt;name&lt;&lt;" "&lt;&lt;date&lt;&lt;endl;
                   outstream&lt;&lt;ipadd&lt;&lt;"  "&lt;&lt;name&lt;&lt;" "&lt;&lt;date&lt;&lt;endl;
                   instream.ignore(256,'\n');
                   }
      }
  
  instream.close();
  outstream.close();
  
          return 0;
  }
  </code></pre>
  
  <p>The hope is to output the values ip &amp; ipadd into one output file, the values stored in name into the second, and date into the third. For those curious, the program sorts through an Apache log and outputs the IP addresses, names, and login times of the user; excluding any from an internal network. I'm sure there are less than desirable practices I've put in, but thanks for taking the time to look at it.</p>