title: Store filenames in array VC++
body: <p>I am trying to get all the filenames into an array . But after reading all the filenames the array only have the last filename;</p>
  
  <pre><code>#include &lt;Windows.h&gt;
  #include &lt;strsafe.h&gt;
  #include &lt;iostream&gt;
  
  
  int main() {
  
      WIN32_FIND_DATA ffd; 
      HANDLE handle = INVALID_HANDLE_VALUE;
      TCHAR *directory = L"D:/*.*";
      LPCWSTR filenames[30] ;
      handle = FindFirstFile(directory, &amp;ffd);
      int count = 0; 
      if (handle != INVALID_HANDLE_VALUE) {
          OutputDebugString(ffd.cFileName);
          do {
              filenames[count++] = ffd.cFileName;
  
              OutputDebugString(filenames[count -1]);
          } while (FindNextFile(handle, &amp;ffd) != 0);
  
      }
      else {
          OutputDebugString(L"Nothing to display \n"); 
      }
  
      for (int i = 0; i &lt; 10; i++) {
          OutputDebugString(filenames[i]);
      }
      FindClose(handle);
      getchar();
      return 0; 
  }
  </code></pre>
  
  <p>What is the problem I have in this code .. 
  Thanks in advance.. </p>