/*

功能:  根据名册中的名单,搜索指定目录下的作业上交情况
思路:  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;
}