Array Inputs
Dec 7, 2013 at 10:05pm UTC
I want the code to get information along a certain row of a text file using an inputted value that is the same the first value on the first column.
The text file has 18 columns and 12 rows.
Currently the code is just reading three zeroes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string SCname[18];
double SC[18][12];
string clas;
double fmyk;
double fc90k;
double fvk;
int main()
{
cout << "\nEnter class: " ;
cin >> clas;
ifstream myinfile;
myinfile.open("test" );
for (int i=0; i<18; i++)
{
myinfile >> SCname[i];
for (int j=0; j<12; j++)
myinfile >> SC[i][j];
}
int i=0;
while (SCname[18]==SCname[i])
{
if (SCname[i]==clas)
{
fmyk = SC[i][1];
fc90k = SC[i][3];
fvk = SC[i][6];
break ;
}
else
{
i=i+1;
}
}
cout << fmyk << endl;
cout << fc90k << endl;
cout << fvk << endl;
}
Topic archived. No new replies allowed.