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[])
{

    if(argc<2)
        pbsolve("model1.txt");
    else
        pbsolve(argv[1]);

    return 0;
}

class Classname {   

    double data[3][3];  

public:
    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 ??

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.