0

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?

2
Contributors
2
Replies
15
Views
2 Years
Discussion Span
Last Post by rela
0

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

0

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

}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.