title: output list of files from popen to ifstream.open
body: <p>Basically I need to open and read a list of files I get from another command.
  For each line of output of popen
   open a file usen ifstream.open</p>
  
  <p>it compiles and if I put the file name directly it works fine, but it doesn't do anything when using popen output. I've seen questions like this but none of this particular way of giving filenames.</p>
  
  <p>here's the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sqlite3.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  
  int main () {
  
      ifstream singlefile;
      FILE *filelist;
      char filename[512];
      string progline;
  
      if(!(filelist = popen("find `pwd` -name \"*.js\"", "r"))){
          return 1;
      }
  
      while( fgets(filename, sizeof(filename), filelist)!=NULL)
      {
          cout &lt;&lt; filename;
          singlefile.open(filename, ifstream::in);
          while ( singlefile.good() )
          {
              getline (singlefile,progline);
              cout &lt;&lt; progline &lt;&lt; endl;
          }
  
          singlefile.close();
      }
  
      pclose(filelist);
  
    return 0;
  
  }
  </code></pre>
  
  <p>next step would be not open each file inside the loop but to store the file list and then open each file.</p>
  
  <p>Thanks</p>