[问题] 如何依序读取文件档

楼主: Toorch (Torch)   2015-04-30 23:54:02
开发平台(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):
我知道以上程式码根本不能编译
想问是否有办法实现依序读取的需求?
作者: chchwy (mat)   2015-04-30 23:56:00
用sprintf()产生档名
作者: johnjohnlin (嗯?)   2015-05-01 00:15:00
boost filesystem + regex?

Links booklink

Contact Us: admin [ a t ] ucptt.com