EvoTalk

03 十二月, 2008

C List Files on Windows

Posted by: asd In: C++| Code Snippet| 程式設計 ()

c 列舉檔名

C++:
  1. #include   <stdio.h>
  2. #include   <io.h>
  3. #include   <time.h>
  4.  
  5. void main(void)
  6. {
  7.     struct   _finddata_t   c_file;
  8.     long   hFile;
  9.  
  10.     if(   (hFile = _findfirst(   "*.* ",   &c_file   )) == -1L)
  11.         printf(   "No   *.c   files   in   current   directory!n "   );
  12.     else
  13.     {
  14.         do
  15.         {
  16.             if (c_file.attrib   &   _A_ARCH)
  17.                 printf("%sn", c_file.name);
  18.         }
  19.         while (_findnext(   hFile,   &c_file   ) == 0);
  20.  
  21.         _findclose(   hFile   );
  22.     }
  23. }

Tags: ,

Releated Posts



No Responses to "C List Files on Windows"

Comment Form