I have a code that read some input data from a text file, and I want to add a loop using WriteModel() to print out the same data like the same format in the text file, can you help me how to do that?

What is WriteModel()? It's not standard C++; it must be some function you got from somewhere. What is it?

This is an example:

// For example this matrix is the input data from model1.txt file

// 0     1  1
// 1     0  1
// 1     1  0

#include "stdafx.h"
extern void pbsolve(char *fname);
#include <iostream>
#include <fstream>
#include "pb.h"

using namespace std;

int main(int argc, char* argv[])


    return 0;

class Classname {   

    double data[3][3];  

    void Read(char *fname);
    void Writedata();
void Classname::Read(char *fname)

{   int i, j;
    ifstream fin(fname);
        fin >> 3;

// read the matrix
    for(i= 0; i<3; i++)
        for(j= 0; j<3; j++)
            fin >> data[i][j];

void Classname::Writedata()
{ // Write the data in the same format

cout ??