#include <windows.h> 
#include <tchar.h>   
 
int main(int argc, char *argv[]){
    WIN32_FIND_DATA FileData;
    BOOL fFinished;
    HANDLE hList;
    FILE *stream;
   
    hList = FindFirstFile("*", &FileData);
    if (hList == INVALID_HANDLE_VALUE){
        printf("No files under this direction");
    }
    else{
              fFinished = FALSE;
               while (!fFinished){
                         if ( strstr(FileData.cFileName,".txt") ){ //判斷副檔名是不是 .txt  
                                  stream = fopen(FileData.cFileName,"r"); //fopen( const char * filename, const char * mode );
                                  if(stream==NULL){
                                            //return;
                                  }
                                  else{ //讀檔                    
                                  }
                                  fclose(stream); 
                           }//if 判斷副檔名是不是 .txt
                          //--------------計算-------------//
                           if (!FindNextFile(hList, &FileData)){
                                   if (GetLastError() == ERROR_NO_MORE_FILES){
                                           fFinished = TRUE;
                                   }
                            }
                 }//while
    }
    FindClose(hList);
    system("PAUSE");
    return EXIT_SUCCESS;
}
 
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Y CP 的頭像
    Y CP

    Y CP的部落格

    Y CP 發表在 痞客邦 留言(0) 人氣()