title: C++ reading multiple input files sequentially
body: <p>I have 47 different files:</p>
  
  <ul>
  <li>001_template.dat </li>
  <li>...</li>
  <li>047_template.dat </li>
  </ul>
  
  <p>in a directory called <em>/data</em>. I need to compare each of these template files to three different query files, also in the directory. These are named:</p>
  
  <ul>
  <li>001_AU01_query.dat</li>
  <li>001_AU12_query.dat</li>
  <li>001_AU17_query.dat. </li>
  </ul>
  
  <p>I know how to get all of this to run, but I will have to cut and paste these 6 lines of code 46 more times and the program will get very long and confusing.</p>
  
  <p><strong>Is there a good way to loop over these files?</strong> Possibly by looping over the template files and then doing three queries for every template? I obviously have a similarity function and a sort function already defined, as well as <code>inputFile</code>. Here is the code I would like to convert: (not homework this is for a facial expression recognition project I have been working on)</p>
  
  <pre><code>int main()
  {
  vector&lt;float&gt; temp01;
  vector&lt;float&gt; temp12;
  vector&lt;float&gt; temp17;
  
  temp01 = similar(inputFile("data/001_AU01_query.dat"), inputFile("data/001_template.dat"));
  sortAndOutput(temp01);
  temp12 = similar(inputFile("data/001_AU12_query.dat"), inputFile("data/001_template.dat"));
  sortAndOutput(temp12);
  temp17 = similar(inputFile("data/001_AU17_query.dat"), inputFile("data/001_template.dat"));
  sortAndOutput(temp17);
  
  }
  </code></pre>