Hello,
I am trying to add integers to a two dimensional vector.
My problem is on line 26. I know this is how you would add the data to an array, but how do you do this for a vector?
Also, is it true you cannot pass an array to a function as a parameter?
int main()
{
const short s = 10;
const short r = 10000;
const string fileName = "Lab9.txt";
vector< vector<short> > matrix;
//short matrix[s][r];
// Open the data file
ifstream fin(fileName.c_str());
if (!fin.is_open())
{
cout << endl << "Unable to open input file " << fileName << endl;
return 1;
}// End if (!fin.is_open())
// Fill up matrix
int temp = 0;
for(int t = 0; t < s ; t++)
{
for(int i = 0; i < r; i++)
{
fin >> temp;
matrix[t][i].push_back(temp);
}// End for(int i = 0; i < r; i++)
}// End for(int t = 0; t < s ; t++)
//insertion_sort(matrix);
cout << matrix[0][9] << endl;
The file compiles when I remove the [t], but I need to keep track of t, because I am trying to create a 10x10000 matrix.
matrix[i].push_back(temp);