title: Using ftw() properly in c
body: <p>I have the following in my code: (Coding in c)</p>
  
  <pre><code>    ftw(argv[2], parseFile, 100)  
  </code></pre>
  
  <p>argv[2] is a local directory path. For instance. argv[2] = "TestCases" and there is a testcases folder in the same directory as my .o file. </p>
  
  <p>My understanding is that this should traverse the directory TestCases and send every file it finds to the function parseFile. </p>
  
  <p>What actually happens is it simply sends my argument to the function parseFile and that is all. What am I doing wrong? How am I suppose to use this properly? </p>
  
  <p>EDIT: This is parseFile: </p>
  
  <pre><code>int parseFile(const char * ftw_filePath,const struct stat * ptr, int flags){
      FILE * file;
      TokenizerT * currFile;
      char fileString[1000], * currWord, * fileName;
  
      fileName = strdup(ftw_filePath);
  
      if( fileName == NULL || strlen(fileName) &lt;= 0){
          free(fileName);
          return -1;
      }
      printf("\n%s\n",fileName);
      if(strcmp(fileName,"-h")== 0){
          printf("To run this program(wordstats) type './wordstat.c' followed by a space followed by the file's directory location. (e.g. Desktop/CS211/Assignment1/test.txt )");
          free(fileName);
          return 1;
      }
      else{
          file=fopen(fileName,"r");
      }
  
      if(!file){
          fprintf(stderr,"Error: File Does not Exist in designated location. Please restart the program and try again.\n");
          free(fileName);
          return 0;
      }
      memset(fileString, '\0', 1000);
  
      while(fscanf(file,"%s", fileString) != EOF){ /* traverses the file line by line*/
              stringToLower(fileString);
              currFile = TKCreate("alphanum",fileString);
  
              while((currWord = TKGetNextToken(currFile)) != NULL) {
  
                  insert_List(currWord, words,fileName);
  
              }
              free(currFile-&gt;delimiters);
              free(currFile-&gt;copied_string);
  
              free(currFile);
          memset(fileString, '\0', 1000);
      }
  
      fclose(file);
      free(fileName);
      return 1;
  }
  </code></pre>
  
  <p>It will work if I input TestCases/big.txt for my argv[2] but not if I put TestCases</p>