Hi there
I am doing a little c++ project.I want to write a code to read some data from a file and save them in the array.A sample of my data look likes this;
#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
usingnamespace std;
int main() {
int x[214831][12]; // 214831 is the number of rows and 12 Num of Culms
int y[10];
int i=0,j=0;
string str;
ifstream two("10.dat");
while (two.good()) {
getline(two,str);
istringstream sin(str);
for (j=0; j<12 ;j++)
sin >>x[i][j];
i++;
}
cout<<"Please enter M's in a row: ";
for (i=0; i<10 ;i++)
cin >>y[i];
j=0;
for (i=0; i<214831 ;i++)
{
if (y[0] ==x[i][j])
if (y[1] ==x[i][j+1])
if (y[2] ==x[i][j+2])
if (y[3] ==x[i][j+3])
if (y[4] ==x[i][j+4])
if (y[5] ==x[i][j+5])
if (y[6] ==x[i][j+6])
if (y[7] ==x[i][j+7])
if (y[8] ==x[i][j+8])
if (y[9] ==x[i][j+9])
cout<<"p="<<x[i][j+10]<<"\t q="<<x[i][j+11]<<endl;
if (y[0] ==-x[i][j])
if (y[1] ==-x[i][j+1])
if (y[2] ==-x[i][j+2])
if (y[3] ==-x[i][j+3])
if (y[4] ==-x[i][j+4])
if (y[5] ==-x[i][j+5])
if (y[6] ==-x[i][j+6])
if (y[7] ==-x[i][j+7])
if (y[8] ==-x[i][j+8])
if (y[9] ==-x[i][j+9])
cout<<"p="<<-x[i][j+10]<<"\t q="<<x[i][j+11]<<endl;
}
two.close();
}
The problem is that it doesn't run. It can open the file but i think problem is somewhere else.
I used longint x[214831][12]; but the problem is still exist.
any help is appreciated.