求助C/C++大神解答
求大神解答
在C盘中有一个MOD的文件夹
里面有1到10000个.mod的文件(实在不行有1到10000个.mod的文件(名字为1,2,3,4......10000的))
里面只包含1-100个大小写字母、数字(不含回车空格和其他字符)
将其输出
不要用打表发如:ifstream a1("C:MOD1.mod") a2("C:MOD2.mod") a3("C:MOD3.mod") ........a10000("C:MOD10000.mod");
string a;
a1>>a;
cout<<a<<endl;
a2>>a;
cout<<a<<endl;
a3>>a;
cout<<a<<endl;
.............
a10000>>a;
cout<<a<<endl;
求大神解答
给你个参考
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
string x="c:mod",f;
for(int i=1; i<=1000000; i++)
{
stringstream s;
s<<i;
f=x+s.str()+".mod";
ifstream a(f.c_str()) ;
cout << a<< endl;
a.close();
}
return 0;
}
热门标签: