Sorry, I am a bit new to c++, but I need to organize data from a txt file into an array (or vector if that's easier), and it needs to have 12 columns and 10000 rows. I need to be able to multiply these columns, but I can't get past putting data into rows. The data is parsed by tabs, and is already in a 12x10000 format. How can I do this only using c++?
I've already tried looking online and I've come with nothing other than to read the text. I have 225 more lines of code that are all the tries I've had at trying to do this. It essentially boils to these lines. I have a parser, but it doesn't do anything but divide the data by tabs, not identify it.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
float array[12][10000]; // creates array to hold names
long loop=0; //short for loop for input
float line; //this will contain the data read from the file
ifstream myfile ("data.txt"); //opening the file.
if (myfile.is_open()) //if the file is open
{
while (! myfile.eof() ) //while the end of file is NOT reached
{
getline (myfile,line); //get one line from the file
array[loop] = line;
cout << array[loop] << endl; //and output it
loop++;
}
myfile.close(); //closing the file
}
else cout << "Unable to open file"; //if the file is not open output
system("PAUSE");
return 0;
}
I expected the outcome to be the data organized into an array or vector (I don't know how to use vectors), inwhich I can multiply columns, but it just falls with the error that I cannot properly put the code in the columns.