How to access content of a folder's file in c? : I have a folder and this folder has 5 text files. I want to read these text files. I know by this code I can have the list of sub folders in a folder:

    #include <dirent.h> 
    #include <stdio.h> 

    int main(void)
    {
      DIR           *d;
      struct dirent *dir;
      d = opendir(folder address);
      if (d)
      {
       while ((dir = readdir(d)) != NULL)
       {
        printf("%s\n", dir->d_name);
       }

      closedir(d);
      }

    return(0);
    }

But I want to read these files (each file content a character) and print this character on the screen. So I used this code:

    int main(void)
    {
      DIR           *d;
      struct dirent *dir;
      d = opendir(folder address);
      if (d)
      {
       while ((dir = readdir(d)) != NULL)
       {

      if(strcmp(dir->d_name,".")==0 || strcmp(dir->d_name,"..")==0 )
      {continue;}

      ifstream myReadFile;
      myReadFile.open(dir->d_name);
      char output;
      if (myReadFile.is_open()) {
      while (!myReadFile.eof()) {
      myReadFile >> output;
      cout<<output<<endl;

     }}

    }

    closedir(d);
    }

    return(0);
    }

But I got no answer. Could you kindly help me please in finding my code's problem?