回覆列表
-
1 # tzdfe4919
-
2 # 快樂與我同行9
讀取的程式碼方式如下:
int main()
{
long file;
struct _finddata_t find;
_chdir("d:\\");
if((file=_findfirst("*.*", &find))==-1L)
{
printf("空白!\n");
exit(0);
}
printf("%s\n", find.name);
while(_findnext(file, &find)==0)
{
printf("%s\n", find.name);
}
_findclose(file);
return 0;
}
#include<stdio.h>#include<io.h>intmain(intargc,char*argv[]){struct_finddata_tfa;longfHandle;if((fHandle=_findfirst("*.txt",&fa))==-1L)//這裡可以改成需要的目錄{printf("當前目錄下沒有txt檔案\n");return0;}elsedo{printf("找到檔案:%s\n",fa.name);}while(_findnext(fHandle,&fa)==0);_findclose(fHandle);return0;}