title: count number of files with a given extension in a directory - C++?
body: <p>Is it possible in c++ to count the number of files with a given extension in a directory?</p>
  
  <p>I'm writing a program where it would be nice to do something like this (pseudo-code):</p>
  
  <pre><code>if (file_extension == ".foo")
      num_files++;
  for (int i = 0; i &lt; num_files; i++)
      // do something
  </code></pre>
  
  <p>Obviously, this program is much more complex, but this should give you the general idea of what I'm trying to do.</p>
  
  <p>If this is not possible, just tell me.</p>
  
  <p>Thanks!</p>