/*

功能:  根據名冊中的名單,搜索指定目錄下的作業上交情況
思路:  fp指向名冊,fp1指向未交名冊,從名冊中檢索出的姓名s
         和制定目錄組串成詳細目錄,_finddata_t按目錄名搜索
*/

#include 
<io.h>
#include 
<stdio.h>
#include 
<stdlib.h>
#include 
<string.h>

int main()
{
    
char szPath[_MAX_PATH] = {0};
    printf(
"請輸入要查看作業的目錄:");
    scanf(
"%s",szPath);

    
int nLen = strlen(szPath);
    
if(szPath[nLen] != '\\')
        szPath[nLen] 
= '\\';

    
char s[16];
    FILE
* fp = fopen("名冊.txt","r");
    _finddata_t fd;
    strcpy(szPath
+nLen+1,"Homework.txt");
    
    FILE
* fp1 = fopen(szPath,"w");
    
while(fgets(s,sizeof(s),fp) >0)
    
{
        
int n = strlen(s);
        s[n
-1= 0;

        strcpy(szPath
+nLen+1,s);
        
if(-1 == _findfirst(szPath,&fd))
        
{
            puts(s);
            s[n
-1= '\n';
            fputs(s,fp1);
        }

    }


    fclose(fp);
    fclose(fp1);
    
    
return 0;
}