Dec 1, 2008 at 6:51pm UTC
Hey everyone, I'm new to this site but I'm fed up with an assignment and I need some assistance.
I need to read a data file into a 2 dimensional array, and I believe that is the hardest part of the assignment. Here's my code:
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <fstream>
using namespace std;
// Global Variables
int FactoryData[6][4]; // ?
int main()
{
// Read Data File into a 2 Dimensional Array
ifstream inFile ("FactoryData.txt", ios::in);
inFile.precision(2);
inFile.setf(ios::fixed, ios::showpoint);
inFile >> // ?
while (!inFile.eof())
{
for (int factory = 0; factory < 6; factory++)
{
for (int shift = 0; shift < 4; shift++)
{
FactoryData[factory][shift] = // ?
}
}
}
inFile.close();
}
This is not my entire code; it's only the part I'm having trouble with
a "?" means that I have no idea what to put there.
Here's the data from the "FactoryData.txt" file:
300 450 500 210
510 600 750 400
627 100 420 430
530 621 730 530
200 050 058 200
100 082 920 290
6 rows, 4 columns
Thank you!
Last edited on Dec 1, 2008 at 8:23pm UTC
Dec 1, 2008 at 9:04pm UTC
Just use inFile >> FactoryData[factory][shift]