C++ 使用for循环在c++;

C++ 使用for循环在c++;,c++,io,C++,Io,我正在尝试将数据写入100个文件gnu 2D\u t0\u Q\u xtu 2sol\u anal.dat,gnu 2D\u t1\u Q\u xtu 2sol\u anal.dat,…,gnu 2D\u t100\u Q\u xtu 2sol\u anal.dat。作为灵感,我想出了以下代码片段 int m = 100; for(int k=0;k<m;k++) { stringstream aa; // http://www.dreamincode.net/forums/

我正在尝试将数据写入100个文件
gnu 2D\u t0\u Q\u xtu 2sol\u anal.dat
gnu 2D\u t1\u Q\u xtu 2sol\u anal.dat
,…,
gnu 2D\u t100\u Q\u xtu 2sol\u anal.dat
。作为灵感,我想出了以下代码片段

int m = 100;
for(int k=0;k<m;k++)
{
    stringstream aa;    // http://www.dreamincode.net/forums/topic/95826-stringstream-tutorial/
    aa << k;
    filename = "gnu_2D_t" + aa.str() + "_Q_xt_2sol_anal.dat";
    files.open(filename.c_str());  // http://www.cplusplus.com/forum/beginner/122208/
    for(int i=0;i<SPACE;i=i+1)
    {
        files << x_begin + (i * h) << setw(18);
        files << Q_xt_matrix[i][t_matrix[m]] << setw(18);
        files << endl;
    }
    files.close;
}

有人知道我的代码有什么问题吗?

close
是一种方法,而不是
文件的成员。将最后一行更改为
files.close()

close
是一个函数。使用
文件.close()
。哦,当然谢谢你,我现在觉得很傻。一旦我被允许,我将接受你的回答。
error: invalid use of non-static member function files.close;
                                                            ^