[問題] 如何依序讀取文件檔

看板C_and_CPP (C/C++)作者 (Torch)時間11年前 (2015/04/30 23:54), 11年前編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Dev C++ 問題(Question): 假設我現在有「a1.txt、a2.txt、a3.txt、...a100.txt」 我要將這些文件檔依序讀取並做出一些處理 不知道是否有辦法? 程式碼(Code):(請善用置底文網頁, 記得排版) #include<stdio.h> #include<stdlib.h> int main() { int a; FILE *file; for(a=1;a<=100;a++){ file = fopen("a%d.txt", a, "w"); //做處理 fclose(file); } return 0; system("PAUSE"); } 補充說明(Supplement): 我知道以上程式碼根本不能編譯 想問是否有辦法實現依序讀取的需求? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.175.168.253 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1430409245.A.CFD.html

04/30 23:56, , 1F
用sprintf()產生檔名
04/30 23:56, 1F

05/01 00:15, , 2F
boost filesystem + regex?
05/01 00:15, 2F
感謝各位 已解決 ※ 編輯: Toorch (1.175.168.253), 05/01/2015 00:38:17
文章代碼(AID): #1LGb0Tpz (C_and_CPP)
文章代碼(AID): #1LGb0Tpz (C_and_CPP)