jeudi 30 mars 2017

File not opening second time in c++

I am trying to open a file using this code which will be called multiple time. First time the file is opening but when this is called for the second time, I am getting some error on the fp1.open.... line, which is:

Error in `/home/prosun/Desktop/workspace/fight/Default/fight': corrupted double-linked list: 0x0000000000675310

The code:

void Writedata::write_file(){

    ofstream fp1;
    int i;

    fp1.open ("output/data.txt"), ios::out | ios::app);
    for(int i = 0; i < 10; i++){
         cout.width(10); fp1 << i << endl;
    }
    fp1.close();
}

Please help me solve this issue.

Aucun commentaire:

Enregistrer un commentaire