![]() |
PCDVD數位科技討論區
(https://www.pcdvd.com.tw/index.php)
- 疑難雜症區
(https://www.pcdvd.com.tw/forumdisplay.php?f=34)
- - (求助C語言)如何用程式讀寫出目錄下所有檔案的檔名
(https://www.pcdvd.com.tw/showthread.php?t=764910)
|
---|
(求助C語言)如何用程式讀寫出目錄下所有檔案的檔名
最近遇到要用C來解決的問題
假設我C:\QQ 目錄下有 11.txt , 22.txt , 33.txt 3個檔案 要如何用C (或C++) 來讀出QQ目錄下檔案的檔名 再寫出到一個LIST的txt檔案中 LIST.txt --------------- 11.txt 22.txt 33.txt 類似這樣呢 請求C高手協助..:cry: |
msdos 的命令
dir *.* > list.txt 想辦法把他加到C裡. |
system("dir > list.txt");
是最直接的方法,不過你會得到檔名以外的其它資訊. c 的函式的話,用 opendir, readdir opendir 回傳一個 DIR 指標 readdir 回傳一個 struct dirent 指標 struct dirent 裡有目錄下的檔案資訊(其實還包含子目錄) |
tree /f
.......... |
system("dir/b > list.txt");
|
所有的時間均為GMT +8。 現在的時間是03:41 PM. |
vBulletin Version 3.0.1
powered_by_vbulletin 2025。