Hey Guys i need your input here..
I created a data file example.dat which looks like:
34 12 14
23 23 54
2 32 67
1 56 7
12 2 67
Then i created a program that extracts the data from the example.dat file and prints in the output as a matrix.. I wrote a program for that and all i get in an endless loop of 67 over and over again
Here is my program code
#include <iostream>
using std::cerr;
using std::cout;
using std::endl;
#include <fstream>
using std::ifstream;
#include <cstdlib> // for exit function
int i, j,A[5][3];
int main()
{
ifstream indata; // indata is like cin
int num; // variable for input value
indata.open("example.dat"); // opens the file
if(!indata) { // file couldn't be opened
cerr << "Error: file could not be opened" << endl;
exit(1);
}
indata >> num;
i= 1;j=1;
while ( !indata.eof() ) { // keep reading until end-of-file
indata >> num; // sets EOF flag if no value found
for (i=1; i<=3; i++) {
for (j=1; j<=5; j++) {
A[i][j]=num;
}
}
}
indata.close();
cout << "End-of-file reached.." << endl;
for (i=1 ;i=3; i++)
{
for (j=1;j=3; j++)
{cout <<A[i][j]<<" ";}
cout <<endl;};
return 0;
}