title: How to access to the content of some files in a same folder in c++?
body: <p>I have a folder and this folder has 5 text files.</p>
  
  <p>I want to read these text files.</p>
  
  <p>I know by this code that, I can have the list of subfolders in a folder:</p>
  
  <pre><code>#include &lt;dirent.h&gt; 
  #include &lt;stdio.h&gt; 
  
  int main(void)
  {
    DIR           *d;
    struct dirent *dir;
    d = opendir("c://myproject/task1");
    if (d)
    {
     while ((dir = readdir(d)) != NULL)
     {
      printf("%s\n", dir-&gt;d_name);
     }
     closedir(d);
    }
    return(0);
  }
  </code></pre>
  
  <p>But, I want to read these files (each files content is a character) and print this character on the screen.</p>
  
  <p>So I used this code:</p>
  
  <pre><code>int main(void)
  {
    DIR           *d;
    struct dirent *dir;
    d = opendir("c://myproject/task1");
    if (d)
    {
     while ((dir = readdir(d)) != NULL)
     {
  
      if(strcmp(dir-&gt;d_name,".")==0 || strcmp(dir-&gt;d_name,"..")==0 )
      {continue;}
  
      ifstream myReadFile;
      myReadFile.open(dir-&gt;d_name);
      char output;
  
      if(myReadFile.is_open())
      {
       while (!myReadFile.eof())
       {
        myReadFile &gt;&gt; output;
        cout&lt;&lt;output&lt;&lt;endl;
       }
      }
     }
     closedir(d);
    }
  
    return(0);
  }
  </code></pre>
  
  <p>But, I get no output.</p>
  
  <p>Could you kindly help me in finding the problem in my code?</p>