我有一个C++代码,可以从目录中读取多个txt文件。但是这些文件是指定的格式,即abc01.txt,abc02.txt,abc03.txt .....,abc99.txt。如何以指定的格式读取C++中的多个txt文件。
我可以读取格式为abc1.txt,abc2.txt,abc3.txt .....,abc99.txt的文件。使用我的代码。问题是我不能读取整数值01至09.
请帮我我如何编辑我的代码并阅读所有文件。
我的代码:
for(files=1;files<=counter;files++)
{ stringstream out;
out<<files;
infile="./input/abc"+out.str()+".txt";
input.open(infile.c_str());
}
残酷而简单。可以避免使用std :: to_string的字符串流。 – user4581301